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.
This commit is contained in:
committed by
GitHub
parent
e8fa45c695
commit
e2e241320b
@@ -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<String> _kRequiredOptions = <String>[
|
||||
_kOptionPackages,
|
||||
_kOptionShell,
|
||||
_kOptionTestDirectory,
|
||||
_kOptionSdkRoot,
|
||||
_kOptionTestFile,
|
||||
_kOptionDillFile,
|
||||
_kOptionIcudtl
|
||||
_kOptionIcudtl,
|
||||
_kOptionTests,
|
||||
];
|
||||
const String _kOptionCoverage = 'coverage';
|
||||
const String _kOptionCoveragePath = 'coverage-path';
|
||||
@@ -54,9 +53,8 @@ Future<Null> run(List<String> 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<Null> run(List<String> 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<Null> run(List<String> args) async {
|
||||
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(
|
||||
<String>[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),
|
||||
);
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ void installHook({
|
||||
bool startPaused = false,
|
||||
int port = 0,
|
||||
String precompiledDillPath,
|
||||
Map<String, String> 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<String, String> 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);
|
||||
|
||||
@@ -29,6 +29,7 @@ Future<int> runTests(
|
||||
bool ipv6 = false,
|
||||
bool machine = false,
|
||||
String precompiledDillPath,
|
||||
Map<String, String> precompiledDillFiles,
|
||||
bool trackWidgetCreation = false,
|
||||
bool updateGoldens = false,
|
||||
TestWatcher watcher,
|
||||
@@ -75,6 +76,7 @@ Future<int> runTests(
|
||||
startPaused: startPaused,
|
||||
serverType: serverType,
|
||||
precompiledDillPath: precompiledDillPath,
|
||||
precompiledDillFiles: precompiledDillFiles,
|
||||
trackWidgetCreation: trackWidgetCreation,
|
||||
updateGoldens: updateGoldens,
|
||||
projectRootDirectory: fs.currentDirectory.uri,
|
||||
|
||||
Reference in New Issue
Block a user