This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds #50058
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1432e6d
release
zijiehe-google-com 1a6d09d
Merge branch 'main' into main
zijiehe-google-com 5679552
Address review comments
zijiehe-google-com 6e15024
Merge branch 'main' into main
zijiehe-google-com 14e8009
Merge branch 'main' into main
zijiehe-google-com c9c3f0d
Address review comments
zijiehe-google-com 82267fc
format
zijiehe-google-com 86bfdc2
==
zijiehe-google-com c08ae5b
Merge branch 'main' into main
zijiehe-google-com f58bfe4
Merge branch 'main' into main
zijiehe-google-com File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,28 @@ | ||
| #!/usr/bin/env python3 | ||
| #!/usr/bin/env vpython3 | ||
|
|
||
| # [VPYTHON:BEGIN] | ||
| # python_version: "3.8" | ||
| # wheel < | ||
| # name: "infra/python/wheels/pyyaml/${platform}_${py_python}_${py_abi}" | ||
| # version: "version:5.4.1.chromium.1" | ||
| # > | ||
| # [VPYTHON:END] | ||
|
|
||
| # Copyright (c) 2013, the Flutter project authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be found | ||
| # in the LICENSE file. | ||
|
|
||
| import argparse | ||
| import logging | ||
| import os | ||
| import sys | ||
|
|
||
| from subprocess import CompletedProcess | ||
| from typing import List | ||
|
|
||
| # The import is coming from vpython wheel and pylint cannot find it. | ||
| import yaml # pylint: disable=import-error | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dnfield do you know how we would go about adding yaml to the engine deps?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| # The imports are coming from fuchsia/test_scripts and pylint cannot find them | ||
| # without setting a global init-hook which is less favorable. | ||
| # But this file will be executed as part of the CI, its correctness of importing | ||
|
|
@@ -25,32 +41,89 @@ | |
| from run_executable_test import ExecutableTestRunner | ||
| from test_runner import TestRunner | ||
|
|
||
| # TODO(https://github.com/flutter/flutter/issues/140179): Respect build | ||
| # configurations. | ||
| OUT_DIR = os.path.join(DIR_SRC_ROOT, 'out/fuchsia_debug_x64') | ||
| if len(sys.argv) == 2: | ||
| VARIANT = sys.argv[1] | ||
| sys.argv.pop() | ||
| elif len(sys.argv) == 1: | ||
| VARIANT = 'fuchsia_debug_x64' | ||
| else: | ||
| assert False, 'Expect only one parameter as the compile output directory.' | ||
| OUT_DIR = os.path.join(DIR_SRC_ROOT, 'out', VARIANT) | ||
|
|
||
|
|
||
| # TODO(https://github.com/flutter/flutter/issues/140179): Execute all the tests | ||
| # in | ||
| # https://github.com/flutter/engine/blob/main/testing/fuchsia/test_suites.yaml | ||
| # and avoid hardcoded paths. | ||
| def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner: | ||
| return ExecutableTestRunner( | ||
| OUT_DIR, [], | ||
| 'fuchsia-pkg://fuchsia.com/dart_runner_tests#meta/dart_runner_tests.cm', | ||
| runner_args.target_id, None, '/tmp/log', | ||
| [os.path.join(OUT_DIR, 'dart_runner_tests.far')], None | ||
| class BundledTestRunner(TestRunner): | ||
|
|
||
| # private, use bundled_test_runner_of function instead. | ||
| def __init__( | ||
| self, target_id: str, package_deps: List[str], tests: List[str], | ||
| logs_dir: str | ||
| ): | ||
| super().__init__(OUT_DIR, [], None, target_id, package_deps) | ||
| self.tests = tests | ||
| self.logs_dir = logs_dir | ||
|
|
||
| def run_test(self) -> CompletedProcess: | ||
| returncode = 0 | ||
| for test in self.tests: | ||
| # pylint: disable=protected-access | ||
| test_runner = ExecutableTestRunner( | ||
| OUT_DIR, [], test, self._target_id, None, self.logs_dir, [], None | ||
| ) | ||
| test_runner._package_deps = self._package_deps | ||
| result = test_runner.run_test().returncode | ||
| logging.warning('Result of test %s is %s', test, result) | ||
zijiehe-google-com marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if result != 0: | ||
| returncode = result | ||
| return CompletedProcess(args='', returncode=returncode) | ||
|
|
||
|
|
||
| def bundled_test_runner_of(target_id: str) -> BundledTestRunner: | ||
| log_dir = os.environ.get('FLUTTER_LOGS_DIR', '/tmp/log') | ||
| with open(os.path.join(os.path.dirname(__file__), 'test_suites.yaml'), | ||
| 'r') as file: | ||
| tests = yaml.safe_load(file) | ||
| # Ignore tests needing multiple packages or with extra test arguments for | ||
zijiehe-google-com marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # now. | ||
| tests = list( | ||
| filter( | ||
| lambda test: test['test_command'].startswith('test run ') and test[ | ||
| 'test_command'].endswith('.cm'), tests | ||
| ) | ||
| ) | ||
| tests = list( | ||
| filter( | ||
| lambda test: 'package' in test and test['package'].endswith('-0.far'), | ||
| tests | ||
| ) | ||
| ) | ||
| tests = list( | ||
| filter( | ||
| lambda test: not 'variant' in test or VARIANT in test['variant'], | ||
| tests | ||
| ) | ||
| ) | ||
| 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']) | ||
| return BundledTestRunner( | ||
| target_id, [test['package'] for test in tests], | ||
| [test['test_command'][len('test run '):] for test in tests], log_dir | ||
| ) | ||
|
|
||
|
|
||
| def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner: | ||
| return bundled_test_runner_of(runner_args.target_id) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| try: | ||
| os.remove(os.path.join(OUT_DIR, 'dart_runner_tests.far')) | ||
| except FileNotFoundError: | ||
| pass | ||
| os.symlink( | ||
| 'dart_runner_tests-0.far', os.path.join(OUT_DIR, 'dart_runner_tests.far') | ||
| ) | ||
| logging.warning('Running tests in %s', OUT_DIR) | ||
zijiehe-google-com marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sys.argv.append('--out-dir=' + OUT_DIR) | ||
| # The 'flutter-test-type' is a place holder and has no specific meaning; the | ||
| # _get_test_runner is overrided. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.