diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart index aaa0f36c72eed..151cdf85050ae 100644 --- a/packages/flutter_tools/bin/fuchsia_tester.dart +++ b/packages/flutter_tools/bin/fuchsia_tester.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:convert' show json; import 'dart:math' as math; import 'package:args/args.dart'; @@ -27,17 +28,15 @@ const String _kOptionPackages = 'packages'; const String _kOptionShell = 'shell'; const String _kOptionTestDirectory = 'test-directory'; const String _kOptionSdkRoot = 'sdk-root'; -const String _kOptionTestFile = 'test-file'; -const String _kOptionDillFile = 'dill-file'; const String _kOptionIcudtl = 'icudtl'; +const String _kOptionTests = 'tests'; const List _kRequiredOptions = [ _kOptionPackages, _kOptionShell, _kOptionTestDirectory, _kOptionSdkRoot, - _kOptionTestFile, - _kOptionDillFile, - _kOptionIcudtl + _kOptionIcudtl, + _kOptionTests, ]; const String _kOptionCoverage = 'coverage'; const String _kOptionCoveragePath = 'coverage-path'; @@ -54,9 +53,8 @@ Future run(List args) async { ..addOption(_kOptionShell, help: 'The Flutter shell binary') ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests') ..addOption(_kOptionSdkRoot, help: 'Path to the SDK platform files') - ..addOption(_kOptionTestFile, help: 'Test file to execute') - ..addOption(_kOptionDillFile, help: 'Precompiled dill file for test') ..addOption(_kOptionIcudtl, help: 'Path to the ICU data file') + ..addOption(_kOptionTests, help: 'Path to json file that maps Dart test files to precompiled dill files') ..addFlag(_kOptionCoverage, defaultsTo: false, negatable: false, @@ -77,8 +75,6 @@ Future run(List args) async { Cache.flutterRoot = tempDir.path; final Directory testDirectory = fs.directory(argResults[_kOptionTestDirectory]); - final File testFile = fs.file(argResults[_kOptionTestFile]); - final File dillFile = fs.file(argResults[_kOptionDillFile]); final String shellPath = argResults[_kOptionShell]; if (!fs.isFileSync(shellPath)) { @@ -115,13 +111,21 @@ Future run(List args) async { collector = new CoverageCollector(); } + + final Map tests = {}; + final List> jsonList = List>.from( + json.decode(fs.file(argResults[_kOptionTests]).readAsStringSync())); + for (Map map in jsonList) { + tests[map['source']] = map['dill']; + } + exitCode = await runTests( - [testFile.path], + tests.keys.toList(), workDir: testDirectory, watcher: collector, ipv6: false, enableObservatory: collector != null, - precompiledDillPath: dillFile.path, + precompiledDillFiles: tests, concurrency: math.max(1, platform.numberOfProcessors - 2), ); diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 1722b2a5b610f..9538df9c8718d 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -70,6 +70,7 @@ void installHook({ bool startPaused = false, int port = 0, String precompiledDillPath, + Map precompiledDillFiles, bool trackWidgetCreation = false, bool updateGoldens = false, int observatoryPort, @@ -89,6 +90,7 @@ void installHook({ host: _kHosts[serverType], port: port, precompiledDillPath: precompiledDillPath, + precompiledDillFiles: precompiledDillFiles, trackWidgetCreation: trackWidgetCreation, updateGoldens: updateGoldens, projectRootDirectory: projectRootDirectory, @@ -339,6 +341,7 @@ class _FlutterPlatform extends PlatformPlugin { this.host, this.port, this.precompiledDillPath, + this.precompiledDillFiles, this.trackWidgetCreation, this.updateGoldens, this.projectRootDirectory, @@ -353,6 +356,7 @@ class _FlutterPlatform extends PlatformPlugin { final InternetAddress host; final int port; final String precompiledDillPath; + final Map precompiledDillFiles; final bool trackWidgetCreation; final bool updateGoldens; final Uri projectRootDirectory; @@ -444,12 +448,17 @@ class _FlutterPlatform extends PlatformPlugin { printTrace('test $ourTestCount: starting shell process'); // If a kernel file is given, then use that to launch the test. - // Otherwise create a "listener" dart that invokes actual test. - String mainDart = precompiledDillPath != null - ? precompiledDillPath - : _createListenerDart(finalizers, ourTestCount, testPath, server); + // If mapping is provided, look kernel file from mapping. + // If all fails, create a "listener" dart that invokes actual test. + String mainDart; + if (precompiledDillPath != null) { + mainDart = precompiledDillPath; + } else if (precompiledDillFiles != null) { + mainDart = precompiledDillFiles[testPath]; + } + mainDart ??= _createListenerDart(finalizers, ourTestCount, testPath, server); - if (precompiledDillPath == null) { + if (precompiledDillPath == null && precompiledDillFiles == null) { // Lazily instantiate compiler so it is built only if it is actually used. compiler ??= new _Compiler(trackWidgetCreation, projectRootDirectory); mainDart = await compiler.compile(mainDart); diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart index 71652c6caf1ae..68b353b50531a 100644 --- a/packages/flutter_tools/lib/src/test/runner.dart +++ b/packages/flutter_tools/lib/src/test/runner.dart @@ -29,6 +29,7 @@ Future runTests( bool ipv6 = false, bool machine = false, String precompiledDillPath, + Map precompiledDillFiles, bool trackWidgetCreation = false, bool updateGoldens = false, TestWatcher watcher, @@ -75,6 +76,7 @@ Future runTests( startPaused: startPaused, serverType: serverType, precompiledDillPath: precompiledDillPath, + precompiledDillFiles: precompiledDillFiles, trackWidgetCreation: trackWidgetCreation, updateGoldens: updateGoldens, projectRootDirectory: fs.currentDirectory.uri,