diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 96ea1bcb5f..b9b2747739 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -100,7 +100,19 @@ class DriveCommand extends RunCommandBase { if (!argResults['use-existing-app']) { printStatus('Starting application: ${argResults["target"]}'); - int result = await appStarter(this, getBuildMode()); + + if (getBuildMode() == BuildMode.release) { + // This is because we need VM service to be able to drive the app. + printError( + 'Flutter Driver does not support running in release mode.\n' + '\n' + 'Use --profile mode for testing application performance.\n' + 'Use --debug (default) mode for testing correctness (with assertions).' + ); + return 1; + } + + int result = await appStarter(this); if (result != 0) { printError('Application failed to start. Will not run test. Quitting.'); return result; @@ -229,14 +241,14 @@ Future findTargetDevice() async { } /// Starts the application on the device given command configuration. -typedef Future AppStarter(DriveCommand command, BuildMode buildMode); +typedef Future AppStarter(DriveCommand command); AppStarter appStarter = startApp; void restoreAppStarter() { appStarter = startApp; } -Future startApp(DriveCommand command, BuildMode buildMode) async { +Future startApp(DriveCommand command) async { String mainPath = findMainDartFile(command.target); if (await fs.type(mainPath) != FileSystemEntityType.FILE) { printError('Tried to run $mainPath, but that file does not exist.'); @@ -248,7 +260,8 @@ Future startApp(DriveCommand command, BuildMode buildMode) async { printTrace('Building an APK.'); int result = await build_apk.buildApk( command.device.platform, - target: command.target + target: command.target, + buildMode: command.getBuildMode() ); if (result != 0) @@ -263,20 +276,22 @@ Future startApp(DriveCommand command, BuildMode buildMode) async { .getPackageForPlatform(command.device.platform); command.device.installApp(package); + Map platformArgs = {}; + if (command.traceStartup) + platformArgs['trace-startup'] = command.traceStartup; + printTrace('Starting application.'); LaunchResult result = await command.device.startApp( package, - buildMode, + command.getBuildMode(), mainPath: mainPath, route: command.route, debuggingOptions: new DebuggingOptions.enabled( - buildMode, + command.getBuildMode(), startPaused: true, observatoryPort: command.debugPort ), - platformArgs: { - 'trace-startup': command.traceStartup, - } + platformArgs: platformArgs ); return result.started ? 0 : 2; diff --git a/packages/flutter_tools/test/drive_test.dart b/packages/flutter_tools/test/drive_test.dart index e6b6295c01..3ef8702434 100644 --- a/packages/flutter_tools/test/drive_test.dart +++ b/packages/flutter_tools/test/drive_test.dart @@ -38,7 +38,7 @@ void main() { targetDeviceFinder = () { throw 'Unexpected call to targetDeviceFinder'; }; - appStarter = (_, __) { + appStarter = (_) { throw 'Unexpected call to appStarter'; }; testRunner = (_) { @@ -75,7 +75,7 @@ void main() { testUsingContext('returns 1 when app fails to run', () async { withMockDevice(); - appStarter = expectAsync((_, __) async => 1); + appStarter = expectAsync((_) async => 1); String testApp = '/some/app/test_driver/e2e.dart'; String testFile = '/some/app/test_driver/e2e_test.dart'; @@ -140,7 +140,7 @@ void main() { String testApp = '/some/app/test/e2e.dart'; String testFile = '/some/app/test_driver/e2e_test.dart'; - appStarter = expectAsync((_, __) { + appStarter = expectAsync((_) { return new Future.value(0); }); testRunner = expectAsync((List testArgs) { @@ -172,7 +172,7 @@ void main() { String testApp = '/some/app/test/e2e.dart'; String testFile = '/some/app/test_driver/e2e_test.dart'; - appStarter = expectAsync((_, __) { + appStarter = expectAsync((_) { return new Future.value(0); }); testRunner = expectAsync((_) {