Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 19ae46a

Browse files
Redo "[Fuchsia] Execute most of the testing/fuchsia/test_suites.yaml on debug and release builds" (#50408)
Reverts #50407, flutter/flutter#142811, redo #50058. Comparing to the original change, this redo disabled lto / link time optimization for x64 release builder. It's a known issue that lto increased the compilation time from <5 min to over 30 min. (See commit a1b104c.) Disabling lto is safe on x64 release since fuchsia assembly uses arm64 release build on smart display instead. But I will send a PSA to the fuchsia team before submitting this change. Following is the original change description. This change implements a BundledTestRunner to run most of the tests in testing/fuchsia/test_suites.yaml as ExecutableTestRunner. - Tests with packages out of out/fuchsia_*_x64/ are ignored for now. - Tests with extra test command line parameters are ignored for now. The BundledTestRunner can share most of the logic in ExecutableTestRunner and avoid reinventing the wheel. This change also fixes the build break of fuchsia_tests in fuchsia_release_x64 which allows tests to run on the build as well. - Tests not built with AOT are filtered out with variant field in test_suites.yaml. Bug: flutter/flutter#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]. <!-- Links --> [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
1 parent fafd8e5 commit 19ae46a

File tree

7 files changed

+124
-33
lines changed

7 files changed

+124
-33
lines changed

ci/builders/linux_fuchsia.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,41 @@
115115
{
116116
"drone_dimensions": [
117117
"device_type=none",
118+
"kvm=1",
118119
"os=Linux"
119120
],
120121
"gclient_variables": {
121-
"download_android_deps": false
122+
"download_android_deps": false,
123+
"run_fuchsia_emu": true
122124
},
123125
"gn": [
124126
"--fuchsia",
125127
"--fuchsia-cpu",
126128
"x64",
127129
"--runtime-mode",
128-
"release"
130+
"release",
131+
"--no-lto"
129132
],
130133
"name": "fuchsia_release_x64",
131134
"ninja": {
132135
"config": "fuchsia_release_x64",
133136
"targets": [
134-
"flutter/shell/platform/fuchsia:fuchsia"
137+
"flutter/shell/platform/fuchsia:fuchsia",
138+
"flutter/shell/platform/fuchsia/dart_runner:dart_runner_tests",
139+
"fuchsia_tests"
135140
]
136-
}
141+
},
142+
"tests": [
143+
{
144+
"name": "x64 emulator based release tests",
145+
"language": "python3",
146+
"script": "flutter/tools/fuchsia/with_envs.py",
147+
"parameters": [
148+
"testing/fuchsia/run_tests.py",
149+
"fuchsia_release_x64"
150+
]
151+
}
152+
]
137153
},
138154
{
139155
"drone_dimensions": [
@@ -158,6 +174,7 @@
158174
"config": "fuchsia_debug_x64",
159175
"targets": [
160176
"flutter/shell/platform/fuchsia:fuchsia",
177+
"flutter/shell/platform/fuchsia/dart_runner:dart_runner_tests",
161178
"fuchsia_tests"
162179
]
163180
},
@@ -176,7 +193,7 @@
176193
]
177194
},
178195
{
179-
"name": "x64 emulator based tests",
196+
"name": "x64 emulator based debug tests",
180197
"language": "python3",
181198
"script": "flutter/tools/fuchsia/with_envs.py",
182199
"parameters": [

shell/platform/fuchsia/dart_runner/embedder/BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ template("create_aot_snapshot") {
5454
# No asserts in debug or release product.
5555
# No asserts in release with flutter_profile=true (non-product)
5656
# Yes asserts in non-product debug.
57-
if (!invoker.product &&
58-
(!(flutter_runtime_mode == "profile") || is_debug)) {
57+
if (!invoker.product && (flutter_runtime_mode == "debug" || is_debug)) {
5958
args += [ "--enable_asserts" ]
6059
}
6160
args += [ rebase_path(shim_kernel) ]

shell/platform/fuchsia/dart_runner/kernel/BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ template("create_kernel_core_snapshot") {
6969
# No asserts in debug or release product.
7070
# No asserts in release with flutter_profile=true (non-product)
7171
# Yes asserts in non-product debug.
72-
if (!invoker.product &&
73-
(is_debug || !(flutter_runtime_mode == "profile"))) {
72+
if (!invoker.product && (is_debug || flutter_runtime_mode == "debug")) {
7473
args += [ "--enable_asserts" ]
7574
}
7675
args += [ rebase_path(platform_dill) ]

shell/platform/fuchsia/dart_runner/vmservice/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ template("aot_snapshot") {
6565
# No asserts in debug or release product.
6666
# No asserts in release with flutter_profile=true (non-product)
6767
# Yes asserts in non-product debug.
68-
if (!product && (!(flutter_runtime_mode == "profile") || is_debug)) {
68+
if (!product && (flutter_runtime_mode == "debug" || is_debug)) {
6969
args += [ "--enable_asserts" ]
7070
}
7171

shell/platform/fuchsia/flutter/kernel/BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ template("core_snapshot") {
7373
# No asserts in debug or release product.
7474
# No asserts in release with flutter_profile=true (non-product)
7575
# Yes asserts in non-product debug.
76-
if (!invoker.product &&
77-
(is_debug || !(flutter_runtime_mode == "profile"))) {
76+
if (!invoker.product && (is_debug || flutter_runtime_mode == "debug")) {
7877
args += [ "--enable_asserts" ]
7978
}
8079
args += [ rebase_path(platform_dill) ]

testing/fuchsia/run_tests.py

Lines changed: 94 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env vpython3
2+
3+
# [VPYTHON:BEGIN]
4+
# python_version: "3.8"
5+
# wheel <
6+
# name: "infra/python/wheels/pyyaml/${platform}_${py_python}_${py_abi}"
7+
# version: "version:5.4.1.chromium.1"
8+
# >
9+
# [VPYTHON:END]
10+
211
# Copyright (c) 2013, the Flutter project authors. All rights reserved.
312
# Use of this source code is governed by a BSD-style license that can be found
413
# in the LICENSE file.
514

615
import argparse
16+
import logging
717
import os
818
import sys
919

20+
from subprocess import CompletedProcess
21+
from typing import List
22+
23+
# The import is coming from vpython wheel and pylint cannot find it.
24+
import yaml # pylint: disable=import-error
25+
1026
# The imports are coming from fuchsia/test_scripts and pylint cannot find them
1127
# without setting a global init-hook which is less favorable.
1228
# But this file will be executed as part of the CI, its correctness of importing
@@ -25,32 +41,89 @@
2541
from run_executable_test import ExecutableTestRunner
2642
from test_runner import TestRunner
2743

28-
# TODO(https://github.com/flutter/flutter/issues/140179): Respect build
29-
# configurations.
30-
OUT_DIR = os.path.join(DIR_SRC_ROOT, 'out/fuchsia_debug_x64')
44+
if len(sys.argv) == 2:
45+
VARIANT = sys.argv[1]
46+
sys.argv.pop()
47+
elif len(sys.argv) == 1:
48+
VARIANT = 'fuchsia_debug_x64'
49+
else:
50+
assert False, 'Expect only one parameter as the compile output directory.'
51+
OUT_DIR = os.path.join(DIR_SRC_ROOT, 'out', VARIANT)
3152

3253

33-
# TODO(https://github.com/flutter/flutter/issues/140179): Execute all the tests
34-
# in
35-
# https://github.com/flutter/engine/blob/main/testing/fuchsia/test_suites.yaml
36-
# and avoid hardcoded paths.
37-
def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner:
38-
return ExecutableTestRunner(
39-
OUT_DIR, [],
40-
'fuchsia-pkg://fuchsia.com/dart_runner_tests#meta/dart_runner_tests.cm',
41-
runner_args.target_id, None, '/tmp/log',
42-
[os.path.join(OUT_DIR, 'dart_runner_tests.far')], None
54+
class BundledTestRunner(TestRunner):
55+
56+
# private, use bundled_test_runner_of function instead.
57+
def __init__(
58+
self, target_id: str, package_deps: List[str], tests: List[str],
59+
logs_dir: str
60+
):
61+
super().__init__(OUT_DIR, [], None, target_id, package_deps)
62+
self.tests = tests
63+
self.logs_dir = logs_dir
64+
65+
def run_test(self) -> CompletedProcess:
66+
returncode = 0
67+
for test in self.tests:
68+
# pylint: disable=protected-access
69+
test_runner = ExecutableTestRunner(
70+
OUT_DIR, [], test, self._target_id, None, self.logs_dir, [], None
71+
)
72+
test_runner._package_deps = self._package_deps
73+
result = test_runner.run_test().returncode
74+
logging.info('Result of test %s is %s', test, result)
75+
if result != 0:
76+
returncode = result
77+
return CompletedProcess(args='', returncode=returncode)
78+
79+
80+
def bundled_test_runner_of(target_id: str) -> BundledTestRunner:
81+
log_dir = os.environ.get('FLUTTER_LOGS_DIR', '/tmp/log')
82+
with open(os.path.join(os.path.dirname(__file__), 'test_suites.yaml'),
83+
'r') as file:
84+
tests = yaml.safe_load(file)
85+
# TODO(zijiehe-google-com): Run tests with multiple packages or with extra
86+
# test arguments, https://github.com/flutter/flutter/issues/140179.
87+
tests = list(
88+
filter(
89+
lambda test: test['test_command'].startswith('test run ') and test[
90+
'test_command'].endswith('.cm'), tests
91+
)
92+
)
93+
tests = list(
94+
filter(
95+
lambda test: 'package' in test and test['package'].endswith('-0.far'),
96+
tests
97+
)
98+
)
99+
tests = list(
100+
filter(
101+
lambda test: not 'variant' in test or VARIANT == test['variant'],
102+
tests
103+
)
104+
)
105+
for test in tests:
106+
original_package = test['package']
107+
test['package'] = os.path.join(
108+
OUT_DIR, test['package'].replace('-0.far', '.far')
109+
)
110+
try:
111+
os.remove(test['package'])
112+
except FileNotFoundError:
113+
pass
114+
os.symlink(original_package, test['package'])
115+
return BundledTestRunner(
116+
target_id, [test['package'] for test in tests],
117+
[test['test_command'][len('test run '):] for test in tests], log_dir
43118
)
44119

45120

121+
def _get_test_runner(runner_args: argparse.Namespace, *_) -> TestRunner:
122+
return bundled_test_runner_of(runner_args.target_id)
123+
124+
46125
if __name__ == '__main__':
47-
try:
48-
os.remove(os.path.join(OUT_DIR, 'dart_runner_tests.far'))
49-
except FileNotFoundError:
50-
pass
51-
os.symlink(
52-
'dart_runner_tests-0.far', os.path.join(OUT_DIR, 'dart_runner_tests.far')
53-
)
126+
logging.info('Running tests in %s', OUT_DIR)
54127
sys.argv.append('--out-dir=' + OUT_DIR)
55128
# The 'flutter-test-type' is a place holder and has no specific meaning; the
56129
# _get_test_runner is overrided.

testing/fuchsia/test_suites.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919
package: flow_tests-0.far
2020
- test_command: test run fuchsia-pkg://fuchsia.com/runtime_tests#meta/runtime_tests.cm
2121
package: runtime_tests-0.far
22+
variant: fuchsia_debug_x64
2223
- test_command: test run fuchsia-pkg://fuchsia.com/shell_tests#meta/shell_tests.cm
2324
package: shell_tests-0.far
25+
variant: fuchsia_debug_x64
2426
- test_command: test run fuchsia-pkg://fuchsia.com/testing_tests#meta/testing_tests.cm
2527
package: testing_tests-0.far
2628
- test_command: test run fuchsia-pkg://fuchsia.com/txt_tests#meta/txt_tests.cm -- --gtest_filter=-ParagraphTest.*
2729
package: txt_tests-0.far
2830
- test_command: test run fuchsia-pkg://fuchsia.com/ui_tests#meta/ui_tests.cm
2931
package: ui_tests-0.far
32+
variant: fuchsia_debug_x64
3033
- test_command: test run fuchsia-pkg://fuchsia.com/embedder_tests#meta/embedder_tests.cm
3134
package: embedder_tests-0.far
35+
variant: fuchsia_debug_x64
3236
- test_command: test run fuchsia-pkg://fuchsia.com/dart_utils_tests#meta/dart_utils_tests.cm
3337
package: dart_utils_tests-0.far
3438
- test_command: test run fuchsia-pkg://fuchsia.com/dart-jit-runner-integration-test#meta/dart-jit-runner-integration-test.cm

0 commit comments

Comments
 (0)