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