From bcd7116beff1a79ed2dfbb4f2e0e223a167d013e Mon Sep 17 00:00:00 2001 From: "zijiehe@" <68449066+zijiehe-google-com@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:17:31 -0800 Subject: [PATCH] [Fuchsia] Run tests with multiple packages (flutter/engine#50219) This change enables tests requiring multiple packages in both debug and release builders; though the AOT test cannot be executed. Also 4 out of 5 suites are excluded from release builder since some of the tests are failing; it's worth extra investigation. MouseInputTest in theory is enabled, it indeed contains only disabled tests. Bug: https://github.com/flutter/flutter/issues/140179 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- .../src/flutter/testing/fuchsia/run_tests.py | 53 ++++++++++++------- .../flutter/testing/fuchsia/test_suites.yaml | 4 ++ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/engine/src/flutter/testing/fuchsia/run_tests.py b/engine/src/flutter/testing/fuchsia/run_tests.py index 40c66be2b96..e99c722f682 100755 --- a/engine/src/flutter/testing/fuchsia/run_tests.py +++ b/engine/src/flutter/testing/fuchsia/run_tests.py @@ -18,7 +18,7 @@ import os import sys from subprocess import CompletedProcess -from typing import List +from typing import List, Set # The import is coming from vpython wheel and pylint cannot find it. import yaml # pylint: disable=import-error @@ -55,10 +55,10 @@ class BundledTestRunner(TestRunner): # private, use bundled_test_runner_of function instead. def __init__( - self, target_id: str, package_deps: List[str], tests: List[str], + self, target_id: str, package_deps: Set[str], tests: List[str], logs_dir: str ): - super().__init__(OUT_DIR, [], None, target_id, package_deps) + super().__init__(OUT_DIR, [], None, target_id, list(package_deps)) self.tests = tests self.logs_dir = logs_dir @@ -82,38 +82,54 @@ def bundled_test_runner_of(target_id: str) -> BundledTestRunner: with open(os.path.join(os.path.dirname(__file__), 'test_suites.yaml'), 'r') as file: tests = yaml.safe_load(file) - # TODO(zijiehe-google-com): Run tests with multiple packages or with extra - # test arguments, https://github.com/flutter/flutter/issues/140179. + # TODO(zijiehe-google-com): Run tests with extra test arguments, + # https://github.com/flutter/flutter/issues/140179. tests = list( filter( lambda test: test['test_command'].startswith('test run ') and test[ 'test_command'].endswith('.cm'), tests ) ) + # TODO(zijiehe-google-com): Run tests with dart aot, + # https://github.com/flutter/flutter/issues/140179. tests = list( filter( - lambda test: 'package' in test and test['package'].endswith('-0.far'), - tests + lambda test: 'run_with_dart_aot' not in test or test[ + 'run_with_dart_aot'] != 'true', tests ) ) tests = list( filter( - lambda test: not 'variant' in test or VARIANT == test['variant'], + lambda test: 'variant' not in test or VARIANT == test['variant'], tests ) ) + packages = set() for test in tests: - original_package = test['package'] - test['package'] = os.path.join( - OUT_DIR, test['package'].replace('-0.far', '.far') - ) - try: - os.remove(test['package']) - except FileNotFoundError: - pass - os.symlink(original_package, test['package']) + if 'package' in test: + packages.add(test['package']) + else: + assert 'packages' in test, \ + 'Expect either one package or a list of packages' + packages.update(test['packages']) + resolved_packages = set() + for package in packages: + if package.endswith('-0.far'): + # Make a symbolic link to match the name of the package itself without the + # '-0.far' suffix. + new_package = os.path.join(OUT_DIR, package.replace('-0.far', '.far')) + try: + # Remove the old one if it exists, usually happen on the devbox, so + # ignore the FileNotFoundError. + os.remove(new_package) + except FileNotFoundError: + pass + os.symlink(package, new_package) + resolved_packages.add(new_package) + else: + resolved_packages.add(os.path.join(OUT_DIR, package)) return BundledTestRunner( - target_id, [test['package'] for test in tests], + target_id, resolved_packages, [test['test_command'][len('test run '):] for test in tests], log_dir ) @@ -123,6 +139,7 @@ def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner: if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) logging.info('Running tests in %s', OUT_DIR) sys.argv.append('--out-dir=' + OUT_DIR) # The 'flutter-test-type' is a place holder and has no specific meaning; the diff --git a/engine/src/flutter/testing/fuchsia/test_suites.yaml b/engine/src/flutter/testing/fuchsia/test_suites.yaml index 876a51ad891..e1ed249563b 100644 --- a/engine/src/flutter/testing/fuchsia/test_suites.yaml +++ b/engine/src/flutter/testing/fuchsia/test_suites.yaml @@ -43,6 +43,7 @@ emulator_arch: - 'x64' - 'arm64' + variant: fuchsia_debug_x64 - test_command: test run fuchsia-pkg://fuchsia.com/dart-aot-runner-integration-test#meta/dart-aot-runner-integration-test.cm run_with_dart_aot: 'true' packages: @@ -58,12 +59,14 @@ - oot_flutter_jit_runner-0.far - gen/flutter/shell/platform/fuchsia/flutter/tests/integration/embedder/child-view/child-view/child-view.far - gen/flutter/shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/parent-view/parent-view.far + variant: fuchsia_debug_x64 - test_command: test run fuchsia-pkg://fuchsia.com/touch-input-test#meta/touch-input-test.cm packages: - touch-input-test-0.far - oot_flutter_jit_runner-0.far - gen/flutter/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/touch-input-view/touch-input-view.far - gen/flutter/shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/embedding-flutter-view/embedding-flutter-view.far + variant: fuchsia_debug_x64 - test_command: test run fuchsia-pkg://fuchsia.com/mouse-input-test#meta/mouse-input-test.cm packages: - mouse-input-test-0.far @@ -74,3 +77,4 @@ - text-input-test-0.far - oot_flutter_jit_runner-0.far - gen/flutter/shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/text-input-view/text-input-view.far + variant: fuchsia_debug_x64