forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fuchsia] Redo - Use chromium test-scripts to download images and exe…
…cute tests (flutter#49940) This change is a redo of flutter#49847. https://github.com/zijiehe-google-com/engine/compare/4530942..main should show the diff between this and the original change; mainly fixes the flutter/flutter#141907. Following paragraph is copied from the original change. This change can be executed from buildroot by ``` python3 flutter/tools/fuchsia/with_envs.py flutter/testing/fuchsia/run_tests.py ``` Bug: flutter/flutter#140179 - [V] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [V] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [V] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [V] I listed at least one issue that this PR fixes in the description above. - [V] 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. - [V] I updated/added relevant documentation (doc comments with `///`). - [V] I signed the [CLA]. - [V] All existing and new tests are passing.
- Loading branch information
1 parent
e2014f0
commit 7c4ed15
Showing
6 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
# 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 os | ||
import sys | ||
|
||
# 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 | ||
# is guaranteed. | ||
|
||
sys.path.insert( | ||
0, | ||
os.path.join( | ||
os.path.dirname(__file__), '../../tools/fuchsia/test_scripts/test/' | ||
) | ||
) | ||
|
||
# pylint: disable=import-error, wrong-import-position | ||
import run_test | ||
from common import DIR_SRC_ROOT | ||
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') | ||
|
||
|
||
# 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 | ||
) | ||
|
||
|
||
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') | ||
) | ||
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. | ||
sys.argv.append('flutter-test-type') | ||
run_test._get_test_runner = _get_test_runner # pylint: disable=protected-access | ||
sys.exit(run_test.main()) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
# 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 os | ||
import platform | ||
import subprocess | ||
import sys | ||
|
||
sys.path.insert( | ||
0, | ||
os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), 'test_scripts/test/') | ||
) | ||
) | ||
|
||
from common import catch_sigterm, wait_for_sigterm | ||
|
||
|
||
def Main(): | ||
""" | ||
Executes the test-scripts with required environment variables. It acts like | ||
/usr/bin/env, but provides some extra functionality to dynamically set up | ||
the environment variables. | ||
""" | ||
# Ensures the signals can be correctly forwarded to the subprocesses. | ||
catch_sigterm() | ||
|
||
os.environ['SRC_ROOT'] = os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), '../../../') | ||
) | ||
# Flutter uses a different repo structure and fuchsia sdk is not in the | ||
# third_party/, so images root and sdk root need to be explicitly set. | ||
os.environ['FUCHSIA_IMAGES_ROOT'] = os.path.join( | ||
os.environ['SRC_ROOT'], 'fuchsia/images/' | ||
) | ||
|
||
assert platform.system() == 'Linux', 'Unsupported OS ' + platform.system() | ||
os.environ['FUCHSIA_SDK_ROOT'] = os.path.join( | ||
os.environ['SRC_ROOT'], 'fuchsia/sdk/linux/' | ||
) | ||
|
||
with subprocess.Popen(sys.argv[1:]) as proc: | ||
try: | ||
proc.wait() | ||
except: | ||
# Use terminate / SIGTERM to allow the subprocess exiting cleanly. | ||
proc.terminate() | ||
return proc.returncode | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(Main()) |