From 6b6b71ffa64e3b75c848d02cdd076e1d0e457426 Mon Sep 17 00:00:00 2001 From: sigmundch Date: Tue, 25 May 2021 10:50:06 -0700 Subject: [PATCH] Pass --local-engine* from dev/bots/test.dart to `pub test` (only web) (#83308) This is bassically reapplying #71721, but only enables it on web tests. There are known issues that several tests under the `integration.shard` depend on a specific platform, and as a result they require some additional flexiblity (bots need to build more than one engine, and the test flags should allow for secondary engines to be picked by such tests). By enabling this on the web-test shard, we will reduce the false positives in the dart-flutter-HHH-web bot. Fixing the more general problem is tracked by #72368. --- dev/bots/test.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 4559d0fa29..ad9d9a18a4 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -54,6 +54,10 @@ final String flutterTester = path.join(flutterRoot, 'bin', 'cache', 'artifacts', /// configuration) -- prefilled with the arguments passed to test.dart. final List flutterTestArgs = []; +/// Environment variables to override the local engine when running `pub test`, +/// if such flags are provided to `test.dart`. +final Map localEngineEnv = {}; + final bool useFlutterTestFormatter = Platform.environment['FLUTTER_TEST_FORMATTER'] == 'true'; const String kShardKey = 'SHARD'; @@ -95,6 +99,12 @@ Future main(List args) async { print('$clock STARTING ANALYSIS'); try { flutterTestArgs.addAll(args); + for (final String arg in args) { + if (arg.startsWith('--local-engine=')) + localEngineEnv['FLUTTER_LOCAL_ENGINE'] = arg.substring('--local-engine='.length); + if (arg.startsWith('--local-engine-src-path=')) + localEngineEnv['FLUTTER_LOCAL_ENGINE_SRC_PATH'] = arg.substring('--local-engine-src-path='.length); + } if (Platform.environment.containsKey(CIRRUS_TASK_NAME)) print('Running task: ${Platform.environment[CIRRUS_TASK_NAME]}'); print('═' * 80); @@ -283,6 +293,7 @@ Future _runWebToolTests() async { testPaths: [path.join('test', 'web.shard')], enableFlutterToolAsserts: true, perTestTimeout: const Duration(minutes: 3), + includeLocalEngineEnv: true, ); } @@ -1273,6 +1284,11 @@ Future _runFlutterWebTest(String workingDirectory, List tests) asy ); } +// TODO(sigmund): includeLocalEngineEnv should default to true. Currently we +// only enable it on flutter-web test because some test suites do not work +// properly when overriding the local engine (for example, because some platform +// dependent targets are only built on some engines). +// See https://github.com/flutter/flutter/issues/72368 Future _pubRunTest(String workingDirectory, { List testPaths, bool enableFlutterToolAsserts = true, @@ -1280,6 +1296,7 @@ Future _pubRunTest(String workingDirectory, { String coverage, bool forceSingleCore = false, Duration perTestTimeout, + bool includeLocalEngineEnv = false, }) async { int cpus; final String cpuVariable = Platform.environment['CPU']; // CPU is set in cirrus.yml @@ -1319,6 +1336,7 @@ Future _pubRunTest(String workingDirectory, { ]; final Map pubEnvironment = { 'FLUTTER_ROOT': flutterRoot, + if (includeLocalEngineEnv) ...localEngineEnv, }; if (Directory(pubCache).existsSync()) { pubEnvironment['PUB_CACHE'] = pubCache;