Rerun test in engine recipe

This is part of https://flutter-review.googlesource.com/c/recipes/+/17560 to retry flaky test steps in Linux Host Engine.

Change-Id: I3cbb42e7833200e0e8b66c005cf41ccef1772ac0
Bug: https://github.com/flutter/flutter/issues/89059
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/17800
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Keyong Han <keyonghan@google.com>
diff --git a/recipes/engine.py b/recipes/engine.py
index 6089b7c..45c04ca 100644
--- a/recipes/engine.py
+++ b/recipes/engine.py
@@ -125,7 +125,12 @@
   args = ['--variant', out_dir, '--type', types, '--engine-capture-core-dump']
   if android_out_dir:
     args.extend(['--android-variant', android_out_dir])
-  api.python('Host Tests for %s' % out_dir, script_path, args, venv=venv_path)
+  def run_test():
+    return api.python('Host Tests for %s' % out_dir, script_path, args, venv=venv_path)
+  # Rerun test step 3 times by default if failing.
+  # TODO(keyonghan): notify tree gardener for test failures/flakes:
+  # https://github.com/flutter/flutter/issues/89308
+  api.retry.wrap(run_test)
 
 
 def ScheduleBuilds(api, builder_name, drone_props):