Modify to use test run instead of test-run

This change allows additional parameters to be passed in when running `ffx test` (such as --gtest_filter)

Follow up CL will remove `run-test-component` and `run-test-suite` logic, fully migrating over tests to run with `ffx test`

Bug:88522
Change-Id: Iab07894946a07231f1178f4169af50c12ff84c4e
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/36580
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Erik Lin <erkln@google.com>
diff --git a/recipes/engine/femu_test.expected/arm64_emulator_arch.json b/recipes/engine/femu_test.expected/arm64_emulator_arch.json
index c4708ec..3a2c8d7 100644
--- a/recipes/engine/femu_test.expected/arm64_emulator_arch.json
+++ b/recipes/engine/femu_test.expected/arm64_emulator_arch.json
@@ -2637,7 +2637,7 @@
     "~followup_annotations": [
       "@@@STEP_LOG_LINE@yaml@# This is a comment.@@@",
       "@@@STEP_LOG_LINE@yaml@- package: v2_test-123.far@@@",
-      "@@@STEP_LOG_LINE@yaml@  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
+      "@@@STEP_LOG_LINE@yaml@  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
       "@@@STEP_LOG_LINE@yaml@  emulator_arch:@@@",
       "@@@STEP_LOG_LINE@yaml@    - arm64@@@",
       "@@@STEP_LOG_END@yaml@@@"
@@ -2677,7 +2677,7 @@
       "@@@STEP_NEST_LEVEL@1@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@# This is a comment.@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@- package: v2_test-123.far@@@",
-      "@@@STEP_LOG_LINE@test_suites.yaml@  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
+      "@@@STEP_LOG_LINE@test_suites.yaml@  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  emulator_arch:@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - arm64@@@",
       "@@@STEP_LOG_END@test_suites.yaml@@@"
@@ -2719,7 +2719,7 @@
       "@@@STEP_LOG_LINE@json.output@      \"arm64\"@@@",
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
       "@@@STEP_LOG_LINE@json.output@    \"package\": \"v2_test-123.far\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@]@@@",
       "@@@STEP_LOG_END@json.output@@@"
diff --git a/recipes/engine/femu_test.expected/invalid_emulator_arch.json b/recipes/engine/femu_test.expected/invalid_emulator_arch.json
index f4a9b00..b8d6d9d 100644
--- a/recipes/engine/femu_test.expected/invalid_emulator_arch.json
+++ b/recipes/engine/femu_test.expected/invalid_emulator_arch.json
@@ -2637,7 +2637,7 @@
     "~followup_annotations": [
       "@@@STEP_LOG_LINE@yaml@# This is a comment.@@@",
       "@@@STEP_LOG_LINE@yaml@- package: v2_test-123.far@@@",
-      "@@@STEP_LOG_LINE@yaml@  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
+      "@@@STEP_LOG_LINE@yaml@  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
       "@@@STEP_LOG_END@yaml@@@"
     ]
   },
@@ -2675,7 +2675,7 @@
       "@@@STEP_NEST_LEVEL@1@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@# This is a comment.@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@- package: v2_test-123.far@@@",
-      "@@@STEP_LOG_LINE@test_suites.yaml@  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
+      "@@@STEP_LOG_LINE@test_suites.yaml@  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm@@@",
       "@@@STEP_LOG_END@test_suites.yaml@@@"
     ]
   },
@@ -2712,7 +2712,7 @@
       "@@@STEP_LOG_LINE@json.output@[@@@",
       "@@@STEP_LOG_LINE@json.output@  {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"package\": \"v2_test-123.far\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@]@@@",
       "@@@STEP_LOG_END@json.output@@@"
diff --git a/recipes/engine/femu_test.expected/run_on_test_specified_arch.json b/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
index 9bce7b6..31936b9 100644
--- a/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
+++ b/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
@@ -2636,7 +2636,7 @@
     "name": "Retrieve list of test suites",
     "~followup_annotations": [
       "@@@STEP_LOG_LINE@yaml@# This is a comment.@@@",
-      "@@@STEP_LOG_LINE@yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm@@@",
+      "@@@STEP_LOG_LINE@yaml@- test_command: test run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm@@@",
       "@@@STEP_LOG_LINE@yaml@  run_with_dart_aot: true@@@",
       "@@@STEP_LOG_LINE@yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@yaml@    - dart-aot-runner-integration-test-0.far@@@",
@@ -2644,7 +2644,7 @@
       "@@@STEP_LOG_LINE@yaml@  emulator_arch:@@@",
       "@@@STEP_LOG_LINE@yaml@    - x64@@@",
       "@@@STEP_LOG_LINE@yaml@    - arm64@@@",
-      "@@@STEP_LOG_LINE@yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',@@@",
+      "@@@STEP_LOG_LINE@yaml@- test_command: test run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',@@@",
       "@@@STEP_LOG_LINE@yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@yaml@    - dart_aot_runner-0.far'@@@",
       "@@@STEP_LOG_LINE@yaml@  emulator_arch:@@@",
@@ -2685,7 +2685,7 @@
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@# This is a comment.@@@",
-      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm@@@",
+      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  run_with_dart_aot: true@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - dart-aot-runner-integration-test-0.far@@@",
@@ -2693,7 +2693,7 @@
       "@@@STEP_LOG_LINE@test_suites.yaml@  emulator_arch:@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - x64@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - arm64@@@",
-      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',@@@",
+      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - dart_aot_runner-0.far'@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  emulator_arch:@@@",
@@ -2741,7 +2741,7 @@
       "@@@STEP_LOG_LINE@json.output@      \"dart-aot-runner-integration-test-0.far\", @@@",
       "@@@STEP_LOG_LINE@json.output@      \"dart_aot_runner-0.far\"@@@",
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test-run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }, @@@",
       "@@@STEP_LOG_LINE@json.output@  {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"emulator_arch\": [@@@",
@@ -2750,7 +2750,7 @@
       "@@@STEP_LOG_LINE@json.output@    \"packages\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      \"dart_aot_runner-0.far\"@@@",
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test-run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@]@@@",
       "@@@STEP_LOG_END@json.output@@@"
diff --git a/recipes/engine/femu_test.expected/test_run_command.json b/recipes/engine/femu_test.expected/test_run_command.json
index eb85152..fa9d2de 100644
--- a/recipes/engine/femu_test.expected/test_run_command.json
+++ b/recipes/engine/femu_test.expected/test_run_command.json
@@ -2636,7 +2636,7 @@
     "name": "Retrieve list of test suites",
     "~followup_annotations": [
       "@@@STEP_LOG_LINE@yaml@# This is a comment.@@@",
-      "@@@STEP_LOG_LINE@yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm@@@",
+      "@@@STEP_LOG_LINE@yaml@- test_command: test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm@@@",
       "@@@STEP_LOG_LINE@yaml@  run_with_dart_aot: true@@@",
       "@@@STEP_LOG_LINE@yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@yaml@    - dart-aot-runner-integration-test-0.far@@@",
@@ -2678,7 +2678,7 @@
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@# This is a comment.@@@",
-      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test-run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm@@@",
+      "@@@STEP_LOG_LINE@test_suites.yaml@- test_command: test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  run_with_dart_aot: true@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@  packages:@@@",
       "@@@STEP_LOG_LINE@test_suites.yaml@    - dart-aot-runner-integration-test-0.far@@@",
@@ -2724,7 +2724,7 @@
       "@@@STEP_LOG_LINE@json.output@      \"dart_aot_runner-0.far\", @@@",
       "@@@STEP_LOG_LINE@json.output@      \"gen/flutter/shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_jit_runner/dart_jit_echo_server/dart_jit_echo_server/dart_jit_echo_server.far\"@@@",
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test-run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"test_command\": \"test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@]@@@",
       "@@@STEP_LOG_END@json.output@@@"
diff --git a/recipes/engine/femu_test.py b/recipes/engine/femu_test.py
index 8801b60..cfae935 100644
--- a/recipes/engine/femu_test.py
+++ b/recipes/engine/femu_test.py
@@ -196,7 +196,7 @@
 
       # Ensure command is well-formed.
       # See https://fuchsia.dev/fuchsia-src/concepts/packages/package_url.
-      match = re.match(r'^(run-test-component|run-test-suite|test-run) (?P<test_far_file>fuchsia-pkg://[0-9a-z\-_\.]+/(?P<name>[0-9a-z\-_\.]+)#meta/[0-9a-z\-_\.]+(\.cm|\.cmx))( +[0-9a-zA-Z\-_*\.: =]+)?$', suite['test_command'])
+      match = re.match(r'^(run-test-component|run-test-suite|test run) (?P<test_far_file>fuchsia-pkg://[0-9a-z\-_\.]+/(?P<name>[0-9a-z\-_\.]+)#meta/[0-9a-z\-_\.]+(\.cm|\.cmx))( +[0-9a-zA-Z\-_*\.: =]+)?$', suite['test_command'])
       if not match:
         raise api.step.StepFailure('Invalid test command: %s' % suite['test_command'])
 
@@ -274,7 +274,7 @@
   with api.context(
       cwd=root_dir), api.step.nest('FEMU Test'), api.step.defer_results():
     for suite in test_suites:
-      if 'test-run' in suite['test_command']:
+      if 'test run' in suite['test_command']:
         with api.step.nest('run FEMU Test %s' % suite['name']):
           # Retrieve the required product bundle
           # Contains necessary images, packages, etc to launch the emulator
@@ -319,8 +319,8 @@
             api.step('publishing {}'.format(package), [fpublish, package])
 
           # Run the actual test
-          api.retry.step('run ffx test',
-                         [ffx, 'test', 'run', suite['test_far_file']])
+          # Test command is guaranteed to be well-formed
+          api.retry.step('run ffx test', [ffx] + suite['test_command'].split(' '))
 
           # Outputs ffx log and emulator_log for debugging
           deferred_dump_step = api.step('ffx log dump', [ffx, 'log', 'dump'])
@@ -829,7 +829,7 @@
       api.step_data(
           'Retrieve list of test suites.parse',
           api.json.output([{
-            'test_command': 'test-run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm',
+            'test_command': 'test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm',
             'packages': [
               'dart-aot-runner-integration-test-0.far',
               'dart_aot_runner-0.far',
@@ -840,7 +840,7 @@
       api.step_data(
           'Retrieve list of test suites.read',
           api.file.read_text('''# This is a comment.
-- test_command: test-run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm
+- test_command: test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm
   run_with_dart_aot: true
   packages:
     - dart-aot-runner-integration-test-0.far
@@ -899,13 +899,13 @@
               'package':
                   'v2_test-123.far',
               'test_command':
-                  'test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm'
+                  'test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm'
           }])),
       api.step_data(
           'Retrieve list of test suites.read',
           api.file.read_text("""# This is a comment.
 - package: v2_test-123.far
-  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm""")),
+  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm""")),
       api.step_data(
           'Read manifest',
           api.file.read_json({'id': '0.20200101.0.1'}),
@@ -954,7 +954,7 @@
     api.step_data(
         'Retrieve list of test suites.parse',
         api.json.output([{
-          'test_command': 'test-run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm',
+          'test_command': 'test run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm',
           'packages': [
             'dart-aot-runner-integration-test-0.far',
             'dart_aot_runner-0.far',
@@ -964,7 +964,7 @@
             'arm64',
           ]
         },{
-          'test_command': 'test-run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',
+          'test_command': 'test run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',
           'packages': [
             'dart_aot_runner-0.far'
           ],
@@ -976,7 +976,7 @@
     api.step_data(
         'Retrieve list of test suites.read',
         api.file.read_text('''# This is a comment.
-- test_command: test-run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm
+- test_command: test run fuchsia-pkg://fuchsia.com/run-on-both-arch#meta/run-on-both-arch.cm
   run_with_dart_aot: true
   packages:
     - dart-aot-runner-integration-test-0.far
@@ -984,7 +984,7 @@
   emulator_arch:
     - x64
     - arm64
-- test_command: test-run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',
+- test_command: test run fuchsia-pkg://fuchsia.com/only-run-on-arm64#meta/only-run-on-arm64',
   packages:
     - dart_aot_runner-0.far'
   emulator_arch:
@@ -1042,14 +1042,14 @@
               'package':
                   'v2_test-123.far',
               'test_command':
-                  'test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm',
+                  'test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm',
               'emulator_arch': ['arm64']
           }])),
       api.step_data(
           'Retrieve list of test suites.read',
           api.file.read_text("""# This is a comment.
 - package: v2_test-123.far
-  test_command: test-run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm
+  test_command: test run fuchsia-pkg://fuchsia.com/v2_test#meta/v2_test.cm
   emulator_arch:
     - arm64""")),
       api.step_data(