Don't hardcode test filters.

Read gtest_filters.yaml to determine disabled tests.

Bug: fxb/73053
Change-Id: Ie7ff054e12d3de5a57b300cedba86f29b09d5cea
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/11680
Reviewed-by: Yilong Li <liyl@google.com>
Reviewed-by: Yuan Zhi <yuanzhi@google.com>
Reviewed-by: David Worsham <dworsham@google.com>
Commit-Queue: Darren Chan <chandarren@google.com>
diff --git a/recipes/femu_test.expected/no_zircon_file.json b/recipes/femu_test.expected/no_zircon_file.json
index b0862d2..d6f2c96 100644
--- a/recipes/femu_test.expected/no_zircon_file.json
+++ b/recipes/femu_test.expected/no_zircon_file.json
@@ -513,6 +513,89 @@
     "name": "Package Fuchsia Artifacts"
   },
   {
+    "cmd": [],
+    "name": "Retrieve list of gtest filters",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@yaml@txt_tests: -ParagraphTest.*@@@",
+      "@@@STEP_LOG_LINE@yaml@fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure@@@",
+      "@@@STEP_LOG_END@yaml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[CACHE]/builder/src/flutter/testing/fuchsia/gtest_filters.yaml",
+      "/path/to/tmp/"
+    ],
+    "cwd": "[CACHE]/builder",
+    "env": {
+      "GOMA_DIR": "[CACHE]/goma/client"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
+      ]
+    },
+    "env_suffixes": {
+      "DEPOT_TOOLS_UPDATE": [
+        "0"
+      ],
+      "PATH": [
+        "RECIPE_REPO[depot_tools]"
+      ]
+    },
+    "infra_step": true,
+    "name": "Retrieve list of gtest filters.read",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@gtest_filters.yaml@txt_tests: -ParagraphTest.*@@@",
+      "@@@STEP_LOG_LINE@gtest_filters.yaml@fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure@@@",
+      "@@@STEP_LOG_END@gtest_filters.yaml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[flutter::yaml]/resources/parse_yaml.py",
+      "--yaml_file",
+      "[CACHE]/builder/src/flutter/testing/fuchsia/gtest_filters.yaml",
+      "--json_file",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[CACHE]/builder",
+    "env": {
+      "GOMA_DIR": "[CACHE]/goma/client"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
+      ]
+    },
+    "env_suffixes": {
+      "DEPOT_TOOLS_UPDATE": [
+        "0"
+      ],
+      "PATH": [
+        "RECIPE_REPO[depot_tools]"
+      ]
+    },
+    "name": "Retrieve list of gtest filters.parse",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"fml_tests\": \"-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"txt_tests\": \"-ParagraphTest.*\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "vpython",
       "-u",
diff --git a/recipes/femu_test.expected/start_femu_with_vdl.json b/recipes/femu_test.expected/start_femu_with_vdl.json
index ef1db44..ca7a306 100644
--- a/recipes/femu_test.expected/start_femu_with_vdl.json
+++ b/recipes/femu_test.expected/start_femu_with_vdl.json
@@ -513,6 +513,89 @@
     "name": "Package Fuchsia Artifacts"
   },
   {
+    "cmd": [],
+    "name": "Retrieve list of gtest filters",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@yaml@txt_tests: -ParagraphTest.*@@@",
+      "@@@STEP_LOG_LINE@yaml@fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure@@@",
+      "@@@STEP_LOG_END@yaml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[CACHE]/builder/src/flutter/testing/fuchsia/gtest_filters.yaml",
+      "/path/to/tmp/"
+    ],
+    "cwd": "[CACHE]/builder",
+    "env": {
+      "GOMA_DIR": "[CACHE]/goma/client"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
+      ]
+    },
+    "env_suffixes": {
+      "DEPOT_TOOLS_UPDATE": [
+        "0"
+      ],
+      "PATH": [
+        "RECIPE_REPO[depot_tools]"
+      ]
+    },
+    "infra_step": true,
+    "name": "Retrieve list of gtest filters.read",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@gtest_filters.yaml@txt_tests: -ParagraphTest.*@@@",
+      "@@@STEP_LOG_LINE@gtest_filters.yaml@fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure@@@",
+      "@@@STEP_LOG_END@gtest_filters.yaml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[flutter::yaml]/resources/parse_yaml.py",
+      "--yaml_file",
+      "[CACHE]/builder/src/flutter/testing/fuchsia/gtest_filters.yaml",
+      "--json_file",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[CACHE]/builder",
+    "env": {
+      "GOMA_DIR": "[CACHE]/goma/client"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[CACHE]/builder/src/third_party/dart/tools/sdks/dart-sdk/bin"
+      ]
+    },
+    "env_suffixes": {
+      "DEPOT_TOOLS_UPDATE": [
+        "0"
+      ],
+      "PATH": [
+        "RECIPE_REPO[depot_tools]"
+      ]
+    },
+    "name": "Retrieve list of gtest filters.parse",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"fml_tests\": \"-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"txt_tests\": \"-ParagraphTest.*\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "vpython",
       "-u",
diff --git a/recipes/femu_test.py b/recipes/femu_test.py
index 46ab695..3ff0c4e 100644
--- a/recipes/femu_test.py
+++ b/recipes/femu_test.py
@@ -17,6 +17,7 @@
     'depot_tools/depot_tools',
     'flutter/json_util',
     'flutter/repo_util',
+    'flutter/yaml',
     'fuchsia/display_util',
     'fuchsia/sdk',
     'fuchsia/ssh',
@@ -176,20 +177,14 @@
 
 def TestFuchsiaFEMU(api):
   """Run flutter tests on FEMU."""
+  checkout = GetCheckoutPath(api)
+  gtest_filters_file = checkout.join('flutter', 'testing', 'fuchsia',
+                                     'gtest_filters.yaml')
+  gtest_filters = api.yaml.read('Retrieve list of gtest filters',
+                                gtest_filters_file, api.json.output())
   test_args = {
-      'txt_tests':
-          '--gtest_filter=-ParagraphTest.*',
-      'fml_tests':
-          '--gtest_filter=-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure',
-      'shell_tests':
-          (
-              '--gtest_filter=-'
-              'ShellTest.ReportTimingsIsCalledLaterInReleaseMode:'
-              'ShellTest.ReportTimingsIsCalledSoonerInNonReleaseMode:'
-              'ShellTest.DisallowedDartVMFlag:'
-              'FuchsiaShellTest.LocaltimesVaryOnTimezoneChanges'),
-      'flutter_runner_scenic_tests':
-          '--gtest_filter=-SessionConnectionTest.*:CalculateNextLatchPointTest.*',
+    test_type: '--gtest_filter={filter}'.format(filter=gtest_filter)
+    for test_type, gtest_filter in gtest_filters.json.output.items()
   }
   flutter_tests, root_dir, isolated_hash = IsolateSymlink(api)
   cmd = ['./run_vdl_test.sh']
@@ -322,6 +317,18 @@
           ),
       ),
       api.step_data(
+          'Retrieve list of gtest filters.parse',
+          api.json.output({
+            'txt_tests': '-ParagraphTest.*',
+            'fml_tests': '-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure'
+          })
+      ),
+      api.step_data(
+          'Retrieve list of gtest filters.read',
+          api.file.read_text('''txt_tests: -ParagraphTest.*
+fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure''')
+      ),
+      api.step_data(
           'Read manifest',
           api.file.read_json({'id': '0.20200101.0.1'}),
       ),
@@ -369,6 +376,18 @@
               vdl_version='g3-revision:vdl_fuchsia_xxxxxxxx_RC00',
           ),),
       api.step_data(
+          'Retrieve list of gtest filters.parse',
+          api.json.output({
+            'txt_tests': '-ParagraphTest.*',
+            'fml_tests': '-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure'
+          })
+      ),
+      api.step_data(
+          'Retrieve list of gtest filters.read',
+          api.file.read_text('''txt_tests: -ParagraphTest.*
+fml_tests: -MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure''')
+      ),
+      api.step_data(
           'Read manifest',
           api.file.read_json({'id': '0.20200101.0.1'}),
       ),