Unverified Commit e2e24132 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Update fuchsia-tester so it takes map of kernel test files (#21573)

* Update fuchsia-tester so it takes map of kernel test files

* Set mainDart correctly. Cleanup nits.
parent e8fa45c6
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:convert' show json;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:args/args.dart'; import 'package:args/args.dart';
...@@ -27,17 +28,15 @@ const String _kOptionPackages = 'packages'; ...@@ -27,17 +28,15 @@ const String _kOptionPackages = 'packages';
const String _kOptionShell = 'shell'; const String _kOptionShell = 'shell';
const String _kOptionTestDirectory = 'test-directory'; const String _kOptionTestDirectory = 'test-directory';
const String _kOptionSdkRoot = 'sdk-root'; const String _kOptionSdkRoot = 'sdk-root';
const String _kOptionTestFile = 'test-file';
const String _kOptionDillFile = 'dill-file';
const String _kOptionIcudtl = 'icudtl'; const String _kOptionIcudtl = 'icudtl';
const String _kOptionTests = 'tests';
const List<String> _kRequiredOptions = <String>[ const List<String> _kRequiredOptions = <String>[
_kOptionPackages, _kOptionPackages,
_kOptionShell, _kOptionShell,
_kOptionTestDirectory, _kOptionTestDirectory,
_kOptionSdkRoot, _kOptionSdkRoot,
_kOptionTestFile, _kOptionIcudtl,
_kOptionDillFile, _kOptionTests,
_kOptionIcudtl
]; ];
const String _kOptionCoverage = 'coverage'; const String _kOptionCoverage = 'coverage';
const String _kOptionCoveragePath = 'coverage-path'; const String _kOptionCoveragePath = 'coverage-path';
...@@ -54,9 +53,8 @@ Future<Null> run(List<String> args) async { ...@@ -54,9 +53,8 @@ Future<Null> run(List<String> args) async {
..addOption(_kOptionShell, help: 'The Flutter shell binary') ..addOption(_kOptionShell, help: 'The Flutter shell binary')
..addOption(_kOptionTestDirectory, help: 'Directory containing the tests') ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests')
..addOption(_kOptionSdkRoot, help: 'Path to the SDK platform files') ..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(_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, ..addFlag(_kOptionCoverage,
defaultsTo: false, defaultsTo: false,
negatable: false, negatable: false,
...@@ -77,8 +75,6 @@ Future<Null> run(List<String> args) async { ...@@ -77,8 +75,6 @@ Future<Null> run(List<String> args) async {
Cache.flutterRoot = tempDir.path; Cache.flutterRoot = tempDir.path;
final Directory testDirectory = final Directory testDirectory =
fs.directory(argResults[_kOptionTestDirectory]); fs.directory(argResults[_kOptionTestDirectory]);
final File testFile = fs.file(argResults[_kOptionTestFile]);
final File dillFile = fs.file(argResults[_kOptionDillFile]);
final String shellPath = argResults[_kOptionShell]; final String shellPath = argResults[_kOptionShell];
if (!fs.isFileSync(shellPath)) { if (!fs.isFileSync(shellPath)) {
...@@ -115,13 +111,21 @@ Future<Null> run(List<String> args) async { ...@@ -115,13 +111,21 @@ Future<Null> run(List<String> args) async {
collector = new CoverageCollector(); collector = new CoverageCollector();
} }
final Map<String, String> tests = <String, String>{};
final List<Map<String, dynamic>> jsonList = List<Map<String, dynamic>>.from(
json.decode(fs.file(argResults[_kOptionTests]).readAsStringSync()));
for (Map<String, dynamic> map in jsonList) {
tests[map['source']] = map['dill'];
}
exitCode = await runTests( exitCode = await runTests(
<String>[testFile.path], tests.keys.toList(),
workDir: testDirectory, workDir: testDirectory,
watcher: collector, watcher: collector,
ipv6: false, ipv6: false,
enableObservatory: collector != null, enableObservatory: collector != null,
precompiledDillPath: dillFile.path, precompiledDillFiles: tests,
concurrency: math.max(1, platform.numberOfProcessors - 2), concurrency: math.max(1, platform.numberOfProcessors - 2),
); );
......
...@@ -70,6 +70,7 @@ void installHook({ ...@@ -70,6 +70,7 @@ void installHook({
bool startPaused = false, bool startPaused = false,
int port = 0, int port = 0,
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
bool updateGoldens = false, bool updateGoldens = false,
int observatoryPort, int observatoryPort,
...@@ -89,6 +90,7 @@ void installHook({ ...@@ -89,6 +90,7 @@ void installHook({
host: _kHosts[serverType], host: _kHosts[serverType],
port: port, port: port,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
projectRootDirectory: projectRootDirectory, projectRootDirectory: projectRootDirectory,
...@@ -339,6 +341,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -339,6 +341,7 @@ class _FlutterPlatform extends PlatformPlugin {
this.host, this.host,
this.port, this.port,
this.precompiledDillPath, this.precompiledDillPath,
this.precompiledDillFiles,
this.trackWidgetCreation, this.trackWidgetCreation,
this.updateGoldens, this.updateGoldens,
this.projectRootDirectory, this.projectRootDirectory,
...@@ -353,6 +356,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -353,6 +356,7 @@ class _FlutterPlatform extends PlatformPlugin {
final InternetAddress host; final InternetAddress host;
final int port; final int port;
final String precompiledDillPath; final String precompiledDillPath;
final Map<String, String> precompiledDillFiles;
final bool trackWidgetCreation; final bool trackWidgetCreation;
final bool updateGoldens; final bool updateGoldens;
final Uri projectRootDirectory; final Uri projectRootDirectory;
...@@ -444,12 +448,17 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -444,12 +448,17 @@ class _FlutterPlatform extends PlatformPlugin {
printTrace('test $ourTestCount: starting shell process'); printTrace('test $ourTestCount: starting shell process');
// If a kernel file is given, then use that to launch the test. // If a kernel file is given, then use that to launch the test.
// Otherwise create a "listener" dart that invokes actual test. // If mapping is provided, look kernel file from mapping.
String mainDart = precompiledDillPath != null // If all fails, create a "listener" dart that invokes actual test.
? precompiledDillPath String mainDart;
: _createListenerDart(finalizers, ourTestCount, testPath, server); 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. // Lazily instantiate compiler so it is built only if it is actually used.
compiler ??= new _Compiler(trackWidgetCreation, projectRootDirectory); compiler ??= new _Compiler(trackWidgetCreation, projectRootDirectory);
mainDart = await compiler.compile(mainDart); mainDart = await compiler.compile(mainDart);
......
...@@ -29,6 +29,7 @@ Future<int> runTests( ...@@ -29,6 +29,7 @@ Future<int> runTests(
bool ipv6 = false, bool ipv6 = false,
bool machine = false, bool machine = false,
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
...@@ -75,6 +76,7 @@ Future<int> runTests( ...@@ -75,6 +76,7 @@ Future<int> runTests(
startPaused: startPaused, startPaused: startPaused,
serverType: serverType, serverType: serverType,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
projectRootDirectory: fs.currentDirectory.uri, projectRootDirectory: fs.currentDirectory.uri,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment