20from subprocess
import CompletedProcess
21from typing
import Any, Iterable, List, Mapping, NamedTuple, Set
32 0, os.path.join(os.path.dirname(__file__),
'../../tools/fuchsia/test_scripts/test/')
37from common
import DIR_SRC_ROOT
38from run_executable_test
import ExecutableTestRunner
39from test_runner
import TestRunner
44elif len(sys.argv) == 1:
45 VARIANT =
'fuchsia_debug_x64'
47 assert False,
'Expect only one parameter as the compile output directory.'
48OUT_DIR = os.path.join(DIR_SRC_ROOT,
'out', VARIANT)
60 def __init__(self, target_id: str, package_deps: Set[str], tests: List[TestCase], logs_dir: str):
61 super().
__init__(OUT_DIR, [],
None, target_id, list(package_deps))
67 for test
in self.
tests:
68 assert test.package.endswith(
'.cm')
69 test_runner = ExecutableTestRunner(
70 OUT_DIR, test.args.split(), test.package, self._target_id,
None, self.
logs_dir, [],
None
73 test_runner._package_deps = self._package_deps
74 result = test_runner.run_test().returncode
75 logging.info(
'Result of test %s is %s', test, result)
78 return CompletedProcess(args=
'', returncode=returncode)
86 packages.add(test[
'package'])
88 assert 'packages' in test, \
89 'Expect either one package or a list of packages'
90 packages.update(test[
'packages'])
91 resolved_packages =
set()
92 for package
in packages:
93 if package.endswith(
'-0.far'):
96 new_package = os.path.join(OUT_DIR, package.replace(
'-0.far',
'.far'))
100 os.remove(new_package)
101 except FileNotFoundError:
103 os.symlink(package, new_package)
104 resolved_packages.add(new_package)
106 resolved_packages.add(os.path.join(OUT_DIR, package))
107 return resolved_packages
113 for test
in [t[
'test_command']
for t
in tests]:
114 assert test.startswith(
'test run ')
115 test = test[
len(
'test run '):]
117 package, args = test.split(
' -- ', 1)
118 test_cases.append(
TestCase(package=package, args=args))
120 test_cases.append(
TestCase(package=test))
124def _bundled_test_runner_of(target_id: str) -> _BundledTestRunner:
125 log_dir = os.environ.get(
'FLUTTER_LOGS_DIR',
'/tmp/log')
126 with open(os.path.join(os.path.dirname(__file__),
'test_suites.yaml'),
'r')
as file:
127 tests = yaml.safe_load(file)
130 def variant(test) -> bool:
131 return 'variant' not in test
or test[
'variant']
in VARIANT
133 tests = [t
for t
in tests
if variant(t)]
137def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner:
138 return _bundled_test_runner_of(runner_args.target_id)
141if __name__ ==
'__main__':
142 logging.basicConfig(level=logging.INFO)
143 logging.info(
'Running tests in %s', OUT_DIR)
144 sys.argv.append(
'--out-dir=' + OUT_DIR)
145 if VARIANT.endswith(
'_arm64')
or VARIANT.endswith(
'_arm64_tester'):
146 sys.argv.append(
'--product=terminal.qemu-arm64')
149 sys.argv.append(
'flutter-test-type')
150 run_test._get_test_runner = _get_test_runner
151 sys.exit(run_test.main())
def __init__(self, str target_id, Set[str] package_deps, List[TestCase] tests, str logs_dir)
CompletedProcess run_test(self)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Set[str] resolve_packages(Iterable[Mapping[str, Any]] tests)
List[TestCase] build_test_cases(Iterable[Mapping[str, Any]] tests)