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

Add --preview-dart-2 to 'flutter drive' (#14858)

* Add --preview-dart-2 to 'flutter drive'

* Run driver side in --preview-dart-2 mode.

* Fix test
parent 1f3eb503
......@@ -73,6 +73,10 @@ class DriveCommand extends RunCommandBase {
valueHelp:
'path'
);
argParser.addFlag('preview-dart-2',
defaultsTo: false,
help: 'Preview Dart 2.0 functionality.');
}
@override
......@@ -130,7 +134,7 @@ class DriveCommand extends RunCommandBase {
Cache.releaseLockEarly();
try {
await testRunner(<String>[testFile], observatoryUri);
await testRunner(<String>[testFile], observatoryUri, argResults['preview-dart-2']);
} catch (error, stackTrace) {
if (error is ToolExit)
rethrow;
......@@ -282,19 +286,23 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
}
/// Runs driver tests.
typedef Future<Null> TestRunner(List<String> testArgs, String observatoryUri);
typedef Future<Null> TestRunner(List<String> testArgs, String observatoryUri, bool previewDart2);
TestRunner testRunner = _runTests;
void restoreTestRunner() {
testRunner = _runTests;
}
Future<Null> _runTests(List<String> testArgs, String observatoryUri) async {
Future<Null> _runTests(List<String> testArgs, String observatoryUri, bool previewDart2) async {
printTrace('Running driver tests.');
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
final List<String> args = testArgs.toList()
..add('--packages=${PackageMap.globalPackagesPath}')
..add('-rexpanded');
if (previewDart2) {
args.add('--preview-dart-2');
}
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
final int result = await runCommandAndStreamOutput(
<String>[dartVmPath]..addAll(dartVmFlags)..addAll(args),
......
......@@ -54,7 +54,7 @@ void main() {
appStarter = (DriveCommand command) {
throw 'Unexpected call to appStarter';
};
testRunner = (List<String> testArgs, String observatoryUri) {
testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) {
throw 'Unexpected call to testRunner';
};
appStopper = (DriveCommand command) {
......@@ -169,7 +169,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded();
});
testRunner = expectAsync2((List<String> testArgs, String observatoryUri) async {
testRunner = expectAsync3((List<String> testArgs, String observatoryUri, bool previewDart2) async {
expect(testArgs, <String>[testFile]);
return null;
});
......@@ -200,7 +200,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded();
});
testRunner = (List<String> testArgs, String observatoryUri) async {
testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) async {
throwToolExit(null, exitCode: 123);
};
appStopper = expectAsync1((DriveCommand command) async {
......
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