From 594738f2d5607c74e071a34a375b9b680f75ca6b Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Sun, 24 Sep 2023 18:22:27 -0700 Subject: [PATCH] In run_tests.py, separate Dart package unit tests from other tests (flutter/engine#46232) This PR creates a new test type for `run_tests.py` called `dart-host`. The tests remaining under the `dart` type are tests that run in `flutter_tester`. The `dart-host` tests run in the Dart CLI. This allows `run_tests.py` to be simplified a bit, and while doing this I spotted a couple of mistakes that were causing some tests not to run. This PR also makes a couple of small style fixes to the build config json files, converting tabs to spaces, and moving some "script" fields before the "parameters" fields. --- .../builders/linux_android_debug_engine.json | 8 +- .../flutter/ci/builders/linux_fuchsia.json | 2 +- .../ci/builders/linux_host_engine.json | 28 +- .../src/flutter/ci/builders/linux_unopt.json | 14 +- .../ci/builders/mac_android_aot_engine.json | 12 +- .../flutter/ci/builders/mac_clang_tidy.json | 4 +- .../flutter/ci/builders/mac_host_engine.json | 18 +- engine/src/flutter/ci/builders/mac_unopt.json | 18 +- .../standalone/linux_android_emulator.json | 22 +- .../ci/builders/standalone/linux_license.json | 2 +- .../ci/builders/standalone/windows_unopt.json | 4 +- .../ci/builders/windows_host_engine.json | 4 +- engine/src/flutter/testing/run_tests.py | 318 +++++------------- .../test/engine_repo_tools_test.dart | 36 +- 14 files changed, 185 insertions(+), 305 deletions(-) diff --git a/engine/src/flutter/ci/builders/linux_android_debug_engine.json b/engine/src/flutter/ci/builders/linux_android_debug_engine.json index 89566df798..7d3b62ef31 100644 --- a/engine/src/flutter/ci/builders/linux_android_debug_engine.json +++ b/engine/src/flutter/ci/builders/linux_android_debug_engine.json @@ -38,6 +38,7 @@ { "language": "python3", "name": "Host Tests for android_jit_release_x86", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "android_jit_release_x86", @@ -46,8 +47,7 @@ "--engine-capture-core-dump", "--android-variant", "android_jit_release_x86" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -93,6 +93,7 @@ { "language": "python3", "name": "Host Tests for android_debug", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "android_debug", @@ -101,8 +102,7 @@ "--engine-capture-core-dump", "--android-variant", "android_debug" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, diff --git a/engine/src/flutter/ci/builders/linux_fuchsia.json b/engine/src/flutter/ci/builders/linux_fuchsia.json index ef964c68b0..e79853486b 100644 --- a/engine/src/flutter/ci/builders/linux_fuchsia.json +++ b/engine/src/flutter/ci/builders/linux_fuchsia.json @@ -154,7 +154,7 @@ "--engine-version", "${REVISION}", "--skip-build", - "--upload" + "--upload" ], "script": "flutter/tools/fuchsia/build_fuchsia_artifacts.py", "language": "python3" diff --git a/engine/src/flutter/ci/builders/linux_host_engine.json b/engine/src/flutter/ci/builders/linux_host_engine.json index 97f535aa1a..aae0ac2835 100644 --- a/engine/src/flutter/ci/builders/linux_host_engine.json +++ b/engine/src/flutter/ci/builders/linux_host_engine.json @@ -53,14 +53,14 @@ { "language": "python3", "name": "Host Tests for host_debug_impeller_vulkan", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug_impeller_vulkan", "--type", "impeller-vulkan", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -110,14 +110,14 @@ { "language": "python3", "name": "Host Tests for host_debug", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug", "--type", - "dart", + "dart,dart-host", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -158,14 +158,14 @@ { "language": "python3", "name": "Host Tests for host_profile", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_profile", "--type", - "dart,engine", + "dart,dart-host,engine", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -216,14 +216,14 @@ { "language": "python3", "name": "Host Tests for host_release", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_release", "--type", - "dart,engine,benchmarks", + "dart,dart-host,engine,benchmarks", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "language": "bash", @@ -233,10 +233,10 @@ { "language": "bash", "name": "Upload metrics dry-run", - "parameters": [ + "script": "flutter/testing/benchmark/upload_metrics.sh", + "parameters": [ "--no-upload" - ], - "script": "flutter/testing/benchmark/upload_metrics.sh" + ] } ] } diff --git a/engine/src/flutter/ci/builders/linux_unopt.json b/engine/src/flutter/ci/builders/linux_unopt.json index 2570f491db..4274c03223 100644 --- a/engine/src/flutter/ci/builders/linux_unopt.json +++ b/engine/src/flutter/ci/builders/linux_unopt.json @@ -38,15 +38,15 @@ { "language": "python3", "name": "test: Host_Tests_for_host_debug_unopt", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug_unopt", "--type", - "dart,engine", + "dart,dart-host,engine", "--engine-capture-core-dump", "--use-sanitizer-suppressions" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "name": "analyze_dart_ui", @@ -104,6 +104,7 @@ { "language": "python3", "name": "test: Host Tests for android_debug_unopt", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "android_debug_unopt", @@ -112,20 +113,19 @@ "--engine-capture-core-dump", "--android-variant", "android_debug_unopt" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "language": "python3", "name": "malioc diff", + "script": "flutter/impeller/tools/malioc_diff.py", "parameters": [ "--before-relative-to-src", "flutter/impeller/tools/malioc.json", "--after-relative-to-src", "out/android_debug_unopt/gen/malioc", "--print-diff" - ], - "script": "flutter/impeller/tools/malioc_diff.py" + ] } ] } diff --git a/engine/src/flutter/ci/builders/mac_android_aot_engine.json b/engine/src/flutter/ci/builders/mac_android_aot_engine.json index 7f2f8861ab..f59354f107 100644 --- a/engine/src/flutter/ci/builders/mac_android_aot_engine.json +++ b/engine/src/flutter/ci/builders/mac_android_aot_engine.json @@ -9,7 +9,7 @@ "out/android_profile/zip_archives/android-arm-profile/darwin-x64.zip" ], "name": "android_profile", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ @@ -48,7 +48,7 @@ "out/android_profile_arm64/zip_archives/android-arm64-profile/darwin-x64.zip" ], "name": "android_profile_arm64", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ @@ -88,7 +88,7 @@ "out/android_profile_x64/zip_archives/android-x64-profile/darwin-x64.zip" ], "name": "android_profile_x64", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ @@ -128,7 +128,7 @@ "out/android_release/zip_archives/android-arm-release/darwin-x64.zip" ], "name": "android_release", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ @@ -167,7 +167,7 @@ "out/android_release_arm64/zip_archives/android-arm64-release/darwin-x64.zip" ], "name": "android_release_arm64", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ @@ -207,7 +207,7 @@ "out/android_release_x64/zip_archives/android-x64-release/darwin-x64.zip" ], "name": "android_release_x64", - "realm": "production" + "realm": "production" } ], "drone_dimensions": [ diff --git a/engine/src/flutter/ci/builders/mac_clang_tidy.json b/engine/src/flutter/ci/builders/mac_clang_tidy.json index 412c3662ab..f68aa4028f 100644 --- a/engine/src/flutter/ci/builders/mac_clang_tidy.json +++ b/engine/src/flutter/ci/builders/mac_clang_tidy.json @@ -72,7 +72,7 @@ "--shard-id=0", "--shard-variants=host_debug,host_debug,host_debug" ], - "max_attempts": 1, + "max_attempts": 1, "script": "flutter/ci/clang_tidy.sh" } ] @@ -201,7 +201,7 @@ "--shard-id=0", "--shard-variants=host_debug" ], - "max_attempts": 1, + "max_attempts": 1, "script": "flutter/ci/clang_tidy.sh" } ] diff --git a/engine/src/flutter/ci/builders/mac_host_engine.json b/engine/src/flutter/ci/builders/mac_host_engine.json index cc3a336302..aca28e9280 100644 --- a/engine/src/flutter/ci/builders/mac_host_engine.json +++ b/engine/src/flutter/ci/builders/mac_host_engine.json @@ -54,14 +54,14 @@ { "language": "python3", "name": "Host Tests for host_debug", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug", "--type", - "dart,engine", + "dart,dart-host,engine", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -113,14 +113,14 @@ { "language": "python3", "name": "Host Tests for host_profile", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_profile", "--type", - "dart,engine", + "dart,dart-host,engine", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -183,13 +183,13 @@ { "language": "python3", "name": "Impeller-golden, dart and engine tests for host_release", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_release", "--type", - "dart,engine,impeller-golden" - ], - "script": "flutter/testing/run_tests.py" + "dart,dart-host,engine,impeller-golden" + ] } ] }, diff --git a/engine/src/flutter/ci/builders/mac_unopt.json b/engine/src/flutter/ci/builders/mac_unopt.json index 4d372bc615..480b96a5c6 100644 --- a/engine/src/flutter/ci/builders/mac_unopt.json +++ b/engine/src/flutter/ci/builders/mac_unopt.json @@ -40,14 +40,14 @@ { "language": "python3", "name": "Host Tests for host_debug_unopt", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug_unopt", "--type", - "dart,engine", + "dart,dart-host,engine", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, @@ -96,6 +96,7 @@ { "language": "python3", "name": "Tests for ios_debug_sim", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "ios_debug_sim", @@ -104,8 +105,7 @@ "--engine-capture-core-dump", "--ios-variant", "ios_debug_sim" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "name": "Scenario App Integration Tests", @@ -205,6 +205,7 @@ { "language": "python3", "name": "Tests for ios_debug_sim_arm64", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "ios_debug_sim_arm64", @@ -213,8 +214,7 @@ "--engine-capture-core-dump", "--ios-variant", "ios_debug_sim_arm64" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "name": "Scenario App Integration Tests", @@ -276,6 +276,7 @@ { "language": "python3", "name": "Tests for ios_debug_sim_arm64_extension_safe", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "ios_debug_sim_arm64_extension_safe", @@ -284,8 +285,7 @@ "--engine-capture-core-dump", "--ios-variant", "ios_debug_sim_arm64_extension_safe" - ], - "script": "flutter/testing/run_tests.py" + ] }, { "name": "Scenario App Integration Tests", diff --git a/engine/src/flutter/ci/builders/standalone/linux_android_emulator.json b/engine/src/flutter/ci/builders/standalone/linux_android_emulator.json index 9166236d97..b2fe54629a 100644 --- a/engine/src/flutter/ci/builders/standalone/linux_android_emulator.json +++ b/engine/src/flutter/ci/builders/standalone/linux_android_emulator.json @@ -25,13 +25,13 @@ "contexts": [ "android_virtual_device" ], - "parameters": [ - "--android-variant", - "android_debug_x64", - "--type", - "android" - ], - "script": "flutter/testing/run_tests.py" + "script": "flutter/testing/run_tests.py", + "parameters": [ + "--android-variant", + "android_debug_x64", + "--type", + "android" + ] }, { "language": "bash", @@ -39,10 +39,10 @@ "contexts": [ "android_virtual_device" ], - "parameters": [ - "android_debug_x64" - ], - "script": "flutter/testing/scenario_app/run_android_tests.sh" + "script": "flutter/testing/scenario_app/run_android_tests.sh", + "parameters": [ + "android_debug_x64" + ] } ] } diff --git a/engine/src/flutter/ci/builders/standalone/linux_license.json b/engine/src/flutter/ci/builders/standalone/linux_license.json index 15a792c79b..494d401ccc 100644 --- a/engine/src/flutter/ci/builders/standalone/linux_license.json +++ b/engine/src/flutter/ci/builders/standalone/linux_license.json @@ -11,7 +11,7 @@ "tests": [ { "name": "licenses check", - "max_attempts": 1, + "max_attempts": 1, "script": "flutter/ci/licenses.sh" } ] diff --git a/engine/src/flutter/ci/builders/standalone/windows_unopt.json b/engine/src/flutter/ci/builders/standalone/windows_unopt.json index 70839194ae..2508f4507d 100644 --- a/engine/src/flutter/ci/builders/standalone/windows_unopt.json +++ b/engine/src/flutter/ci/builders/standalone/windows_unopt.json @@ -26,14 +26,14 @@ { "language": "python3", "name": "test: Host Tests for host_debug_unopt", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug_unopt", "--type", "engine", "--engine-capture-core-dump" - ], - "script": "flutter/testing/run_tests.py" + ] } ] } diff --git a/engine/src/flutter/ci/builders/windows_host_engine.json b/engine/src/flutter/ci/builders/windows_host_engine.json index 729d62bdcf..12c4542b85 100644 --- a/engine/src/flutter/ci/builders/windows_host_engine.json +++ b/engine/src/flutter/ci/builders/windows_host_engine.json @@ -46,13 +46,13 @@ { "language": "python3", "name": "Host Tests for host_debug", + "script": "flutter/testing/run_tests.py", "parameters": [ "--variant", "host_debug", "--type", "engine" - ], - "script": "flutter/testing/run_tests.py" + ] } ] }, diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 9c4a6c254d..9a0e24f4f1 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -863,83 +863,85 @@ def gather_dart_tests(build_dir, test_filter): yield gather_dart_test(build_dir, dart_test_file, False) -def gather_dart_smoke_test(build_dir): +def gather_dart_smoke_test(build_dir, test_filter): smoke_test = os.path.join( - BUILDROOT_DIR, 'flutter', 'testing', 'smoke_test_failure', - 'fail_test.dart' + BUILDROOT_DIR, + 'flutter', + 'testing', + 'smoke_test_failure', + 'fail_test.dart', ) - yield gather_dart_test(build_dir, smoke_test, True, expect_failure=True) - yield gather_dart_test(build_dir, smoke_test, False, expect_failure=True) + if test_filter is not None and os.path.basename(smoke_test + ) not in test_filter: + logger.info("Skipping '%s' due to filter.", smoke_test) + else: + yield gather_dart_test(build_dir, smoke_test, True, expect_failure=True) + yield gather_dart_test(build_dir, smoke_test, False, expect_failure=True) -def gather_front_end_server_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'flutter_frontend_server') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) +def gather_dart_package_tests(build_dir, package_path, extra_opts): + dart_tests = glob.glob('%s/test/*_test.dart' % package_path) + if not dart_tests: + raise Exception('No tests found for Dart package at %s' % package_path) for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', dart_test_file, build_dir, - os.path.join(build_dir, 'gen', 'frontend_server.dart.snapshot'), - os.path.join(build_dir, 'flutter_patched_sdk') - ] + opts = ['--disable-dart-dev', dart_test_file] + extra_opts yield EngineExecutableTask( build_dir, os.path.join('dart-sdk', 'bin', 'dart'), None, flags=opts, - cwd=test_dir + cwd=package_path ) -def gather_path_ops_tests(build_dir): - # TODO(dnfield): https://github.com/flutter/flutter/issues/107321 - if is_asan(build_dir): - return - - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'path_ops', 'dart', 'test' - ) - opts = ['--disable-dart-dev', os.path.join(test_dir, 'path_ops_test.dart')] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_const_finder_tests(build_dir): - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'const_finder', 'test' - ) - opts = [ - '--disable-dart-dev', - os.path.join(test_dir, 'const_finder_test.dart'), - os.path.join(build_dir, 'gen', 'frontend_server.dart.snapshot'), - os.path.join(build_dir, 'flutter_patched_sdk'), - os.path.join(build_dir, 'dart-sdk', 'lib', 'libraries.json') +# Returns a list of Dart packages to test. +# +# The first element of each tuple in the returned list is the path to the Dart +# package to test. It is assumed that the packages follow the convention that +# tests are named as '*_test.dart', and reside under a directory called 'test'. +# +# The second element of each tuple is a list of additional command line +# arguments to pass to each of the packages tests. +def build_dart_host_test_list(build_dir): + dart_host_tests = [ + ( + os.path.join('flutter', 'ci'), + [os.path.join(BUILDROOT_DIR, 'flutter')], + ), + ( + os.path.join('flutter', 'flutter_frontend_server'), + [ + build_dir, + os.path.join(build_dir, 'gen', 'frontend_server.dart.snapshot'), + os.path.join(build_dir, 'flutter_patched_sdk') + ], + ), + (os.path.join('flutter', 'testing', 'litetest'), []), + ( + os.path.join('flutter', 'tools', 'api_check'), + [os.path.join(BUILDROOT_DIR, 'flutter')], + ), + (os.path.join('flutter', 'tools', 'build_bucket_golden_scraper'), []), + (os.path.join('flutter', 'tools', 'clang_tidy'), []), + ( + os.path.join('flutter', 'tools', 'const_finder'), + [ + os.path.join(build_dir, 'gen', 'frontend_server.dart.snapshot'), + os.path.join(build_dir, 'flutter_patched_sdk'), + os.path.join(build_dir, 'dart-sdk', 'lib', 'libraries.json'), + ], + ), + (os.path.join('flutter', 'tools', 'githooks'), []), + (os.path.join('flutter', 'tools', 'pkg', 'engine_build_configs'), []), + (os.path.join('flutter', 'tools', 'pkg', 'engine_repo_tools'), []), + (os.path.join('flutter', 'tools', 'pkg', 'git_repo_tools'), []), ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) + if not is_asan(build_dir): + dart_host_tests += [ + (os.path.join('flutter', 'tools', 'path_ops', 'dart'), []), + ] - -def gather_litetest_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'testing', 'litetest') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = ['--disable-dart-dev', dart_test_file] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) + return dart_host_tests def run_benchmark_tests(build_dir): @@ -956,157 +958,6 @@ def run_benchmark_tests(build_dir): ) -def gather_githooks_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'tools', 'githooks') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = ['--disable-dart-dev', dart_test_file] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_clang_tidy_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'tools', 'clang_tidy') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', dart_test_file, - os.path.join(build_dir, 'compile_commands.json'), - os.path.join(BUILDROOT_DIR, 'flutter') - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_build_bucket_golden_scraper_tests(build_dir): - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'build_bucket_golden_scraper' - ) - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', - dart_test_file, - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_engine_build_configs_tests(build_dir): - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'pkg', 'engine_build_configs' - ) - dart_tests = glob.glob('%s/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', - dart_test_file, - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_engine_repo_tools_tests(build_dir): - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'pkg', 'engine_repo_tools' - ) - dart_tests = glob.glob('%s/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', - dart_test_file, - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_git_repo_tools_tests(build_dir): - test_dir = os.path.join( - BUILDROOT_DIR, 'flutter', 'tools', 'pkg', 'git_repo_tools' - ) - dart_tests = glob.glob('%s/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', - dart_test_file, - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_api_consistency_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'tools', 'api_check') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', dart_test_file, - os.path.join(BUILDROOT_DIR, 'flutter') - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - -def gather_ci_tests(build_dir): - test_dir = os.path.join(BUILDROOT_DIR, 'flutter', 'ci') - dart_tests = glob.glob('%s/test/*_test.dart' % test_dir) - - run_engine_executable( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=['pub', 'get', '--offline'], - cwd=test_dir, - ) - - for dart_test_file in dart_tests: - opts = [ - '--disable-dart-dev', dart_test_file, - os.path.join(BUILDROOT_DIR, 'flutter') - ] - yield EngineExecutableTask( - build_dir, - os.path.join('dart-sdk', 'bin', 'dart'), - None, - flags=opts, - cwd=test_dir - ) - - def worker_init(queue, level): queue_handler = logging.handlers.QueueHandler(queue) log = logging.getLogger(__name__) @@ -1204,6 +1055,7 @@ Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testin all_types = [ 'engine', 'dart', + 'dart-host', 'benchmarks', 'java', 'android', @@ -1236,7 +1088,13 @@ Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testin '--dart-filter', type=str, default='', - help='A list of Dart test scripts to run.' + help='A list of Dart test scripts to run in flutter_tester.' + ) + parser.add_argument( + '--dart-host-filter', + type=str, + default='', + help='A list of Dart test scripts to run with the Dart CLI.' ) parser.add_argument( '--java-filter', @@ -1367,22 +1225,28 @@ Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testin if 'dart' in types: dart_filter = args.dart_filter.split(',') if args.dart_filter else None - tasks = list(gather_dart_smoke_test(build_dir)) - tasks += list(gather_litetest_tests(build_dir)) - tasks += list(gather_githooks_tests(build_dir)) - tasks += list(gather_clang_tidy_tests(build_dir)) - tasks += list(gather_build_bucket_golden_scraper_tests(build_dir)) - tasks += list(gather_engine_build_configs_tests(build_dir)) - tasks += list(gather_engine_repo_tools_tests(build_dir)) - tasks += list(gather_git_repo_tools_tests(build_dir)) - tasks += list(gather_api_consistency_tests(build_dir)) - tasks += list(gather_path_ops_tests(build_dir)) - tasks += list(gather_const_finder_tests(build_dir)) - tasks += list(gather_front_end_server_tests(build_dir)) - tasks += list(gather_ci_tests(build_dir)) + tasks = list(gather_dart_smoke_test(build_dir, dart_filter)) tasks += list(gather_dart_tests(build_dir, dart_filter)) success = success and run_engine_tasks_in_parallel(tasks) + if 'dart-host' in types: + dart_filter = args.dart_host_filter.split( + ',' + ) if args.dart_host_filter else None + dart_host_packages = build_dart_host_test_list(build_dir) + tasks = [] + for dart_host_package, extra_opts in dart_host_packages: + if dart_filter is None or dart_host_package in dart_filter: + tasks += list( + gather_dart_package_tests( + build_dir, + os.path.join(BUILDROOT_DIR, dart_host_package), + extra_opts, + ) + ) + + success = success and run_engine_tasks_in_parallel(tasks) + if 'java' in types: assert not is_windows( ), "Android engine files can't be compiled on Windows." diff --git a/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart b/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart index 8e34590ba8..4b6a05becb 100644 --- a/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart +++ b/engine/src/flutter/tools/pkg/engine_repo_tools/test/engine_repo_tools_test.dart @@ -202,20 +202,36 @@ void main() { try { // Create a valid engine. - io.Directory(p.join(emptyDir.path, 'src', 'flutter')).createSync(recursive: true); - io.Directory(p.join(emptyDir.path, 'src', 'out')).createSync(recursive: true); + final io.Directory srcDir = io.Directory(p.join(emptyDir.path, 'src')) + ..createSync(recursive: true); + final io.Directory flutterDir = io.Directory(p.join(srcDir.path, 'flutter')) + ..createSync(recursive: true); + final io.Directory outDir = io.Directory(p.join(srcDir.path, 'out')) + ..createSync(recursive: true); // Create two targets in out: host_debug and host_debug_unopt_arm64. - io.Directory(p.join(emptyDir.path, 'src', 'out', 'host_debug')).createSync(recursive: true); - io.Directory(p.join(emptyDir.path, 'src', 'out', 'host_debug_unopt_arm64')).createSync(recursive: true); + final io.Directory hostDebug = io.Directory(p.join(outDir.path, 'host_debug')) + ..createSync(recursive: true); + final io.Directory hostDebugUnoptArm64 = io.Directory( + p.join(outDir.path, 'host_debug_unopt_arm64'), + )..createSync(recursive: true); - // Intentionnally make host_debug a day old to ensure it is not picked. - final io.File oldJson = io.File(p.join(emptyDir.path, 'src', 'out', 'host_debug', 'compile_commands.json'))..createSync(); - oldJson.setLastModifiedSync(oldJson.lastModifiedSync().subtract(const Duration(days: 1))); + final Engine engine = TestEngine.withPaths( + srcDir: srcDir, + flutterDir: flutterDir, + outDir: outDir, + outputs: [ + TestOutput( + hostDebug, + lastModified: DateTime.utc(2023, 9, 23, 21, 16), + ), + TestOutput( + hostDebugUnoptArm64, + lastModified: DateTime.utc(2023, 9, 23, 22, 16), + ), + ], + ); - io.File(p.join(emptyDir.path, 'src', 'out', 'host_debug_unopt_arm64', 'compile_commands.json')).createSync(); - - final Engine engine = Engine.fromSrcPath(p.join(emptyDir.path, 'src')); final Output? latestOutput = engine.latestOutput(); expect(latestOutput, isNotNull); expect(p.basename(latestOutput!.path.path), 'host_debug_unopt_arm64');