Update driver script to execute test through test_core (#24168)
This commit is contained in:
@@ -64,6 +64,13 @@ class DriveCommand extends RunCommandBase {
|
||||
'extension, so e.g. if the target is "lib/main.dart", the driver will be '
|
||||
'"test_driver/main_test.dart".',
|
||||
valueHelp: 'path',
|
||||
)
|
||||
..addFlag('use-test-core',
|
||||
help: 'Run the driver script through the package:test_core entrypoint instead of'
|
||||
' invoking it directly. This is only required if the driver script does not'
|
||||
' import package:test.',
|
||||
defaultsTo: false,
|
||||
negatable: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,6 +93,7 @@ class DriveCommand extends RunCommandBase {
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final String testFile = _getTestFile();
|
||||
final bool useTestCore = argResults['use-test-core'];
|
||||
if (testFile == null)
|
||||
throwToolExit(null);
|
||||
|
||||
@@ -122,7 +130,7 @@ class DriveCommand extends RunCommandBase {
|
||||
Cache.releaseLockEarly();
|
||||
|
||||
try {
|
||||
await testRunner(<String>[testFile], observatoryUri);
|
||||
await testRunner(<String>[testFile], observatoryUri, useTestCore);
|
||||
} catch (error, stackTrace) {
|
||||
if (error is ToolExit)
|
||||
rethrow;
|
||||
@@ -276,29 +284,40 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
|
||||
}
|
||||
|
||||
/// Runs driver tests.
|
||||
typedef TestRunner = Future<void> Function(List<String> testArgs, String observatoryUri);
|
||||
typedef TestRunner = Future<void> Function(List<String> testArgs, String observatoryUri, bool useTestCore);
|
||||
TestRunner testRunner = _runTests;
|
||||
void restoreTestRunner() {
|
||||
testRunner = _runTests;
|
||||
}
|
||||
|
||||
Future<void> _runTests(List<String> testArgs, String observatoryUri) async {
|
||||
Future<void> _runTests(List<String> testArgs, String observatoryUri, bool useTestCore) async {
|
||||
printTrace('Running driver tests.');
|
||||
|
||||
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
|
||||
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
|
||||
final int result = await runCommandAndStreamOutput(
|
||||
<String>[dartVmPath]
|
||||
..addAll(dartVmFlags)
|
||||
final String testScript = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'lib', 'src', 'test', 'drive_executable.dart');
|
||||
final List<String> command = <String>[dartVmPath]
|
||||
..addAll(dartVmFlags);
|
||||
if (useTestCore) {
|
||||
command
|
||||
..addAll(<String>['--packages=${PackageMap.globalPackagesPath}', testScript])
|
||||
..addAll(testArgs)
|
||||
..add('-rexpanded');
|
||||
} else {
|
||||
command
|
||||
..addAll(testArgs)
|
||||
..addAll(<String>[
|
||||
'--packages=${PackageMap.globalPackagesPath}',
|
||||
'-rexpanded',
|
||||
]),
|
||||
environment: <String, String>{ 'VM_SERVICE_URL': observatoryUri }
|
||||
]);
|
||||
}
|
||||
final int result = await runCommandAndStreamOutput(
|
||||
command,
|
||||
environment: <String, String>{ 'VM_SERVICE_URL': observatoryUri },
|
||||
);
|
||||
if (result != 0)
|
||||
if (result != 0) {
|
||||
throwToolExit('Driver tests failed: $result', exitCode: result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
packages/flutter_tools/lib/src/test/drive_executable.dart
Normal file
10
packages/flutter_tools/lib/src/test/drive_executable.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:test_core/src/executable.dart' as executable; // ignore: implementation_imports
|
||||
|
||||
// A trivial wrapper around test_core.
|
||||
Future<void> main(List<String> args) async {
|
||||
await executable.main(args);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
|
||||
dependencies:
|
||||
# To update these, use "flutter update-packages --force-upgrade".
|
||||
analyzer: 0.33.3
|
||||
analyzer: 0.33.3+2
|
||||
archive: 2.0.4
|
||||
args: 1.5.1
|
||||
cli_util: 0.1.3+2
|
||||
@@ -51,12 +51,12 @@ dependencies:
|
||||
convert: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
dart2_constant: 1.0.2+dart2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
front_end: 0.1.6+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
front_end: 0.1.6+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
html: 0.13.3+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
kernel: 0.3.6+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
kernel: 0.3.6+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
package_resolver: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -94,4 +94,4 @@ dartdoc:
|
||||
# Exclude this package from the hosted API docs.
|
||||
nodoc: true
|
||||
|
||||
# PUBSPEC CHECKSUM: 1368
|
||||
# PUBSPEC CHECKSUM: 1cc9
|
||||
|
||||
@@ -53,7 +53,7 @@ void main() {
|
||||
appStarter = (DriveCommand command) {
|
||||
throw 'Unexpected call to appStarter';
|
||||
};
|
||||
testRunner = (List<String> testArgs, String observatoryUri) {
|
||||
testRunner = (List<String> testArgs, String observatoryUri, bool useTestCore) {
|
||||
throw 'Unexpected call to testRunner';
|
||||
};
|
||||
appStopper = (DriveCommand command) {
|
||||
@@ -171,7 +171,7 @@ void main() {
|
||||
appStarter = expectAsync1((DriveCommand command) async {
|
||||
return LaunchResult.succeeded();
|
||||
});
|
||||
testRunner = expectAsync2((List<String> testArgs, String observatoryUri) async {
|
||||
testRunner = expectAsync3((List<String> testArgs, String observatoryUri, bool useTestCore) async {
|
||||
expect(testArgs, <String>[testFile]);
|
||||
return null;
|
||||
});
|
||||
@@ -202,7 +202,7 @@ void main() {
|
||||
appStarter = expectAsync1((DriveCommand command) async {
|
||||
return LaunchResult.succeeded();
|
||||
});
|
||||
testRunner = (List<String> testArgs, String observatoryUri) async {
|
||||
testRunner = (List<String> testArgs, String observatoryUri, bool useTestCore) async {
|
||||
throwToolExit(null, exitCode: 123);
|
||||
};
|
||||
appStopper = expectAsync1((DriveCommand command) async {
|
||||
|
||||
Reference in New Issue
Block a user