From a3a350df1cb59dfb3c7b96b4021a600d6218bda7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 26 Jul 2019 10:06:56 -0700 Subject: [PATCH] devicelab: replace the FLUTTER_ENGINE environment variable with the new local engine flags (#36969) --- dev/devicelab/bin/tasks/flutter_run_test.dart | 3 +- dev/devicelab/lib/framework/utils.dart | 58 ++++--------------- dev/devicelab/lib/tasks/hot_mode_tests.dart | 5 +- dev/devicelab/lib/tasks/microbenchmarks.dart | 3 +- dev/devicelab/lib/tasks/perf_tests.dart | 3 - dev/devicelab/lib/tasks/run_without_leak.dart | 3 +- .../lib/tasks/web_dev_mode_tests.dart | 5 +- 7 files changed, 18 insertions(+), 62 deletions(-) diff --git a/dev/devicelab/bin/tasks/flutter_run_test.dart b/dev/devicelab/bin/tasks/flutter_run_test.dart index 6106fdee03..b461c83883 100644 --- a/dev/devicelab/bin/tasks/flutter_run_test.dart +++ b/dev/devicelab/bin/tasks/flutter_run_test.dart @@ -36,11 +36,10 @@ Future createFlutterRunTask() async { final List options = [ '-t', runTestSource.absolute.path, '-d', device.deviceId, ]; - setLocalEngineOptionIfNecessary(options); await inDirectory(flutterGalleryDir, () async { startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: null, ); final Completer finished = Completer(); diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index 4cb5ed7fb5..a18602891a 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -13,8 +13,6 @@ import 'package:path/path.dart' as path; import 'package:process/process.dart'; import 'package:stack_trace/stack_trace.dart'; -import 'adb.dart'; - /// Virtual current working directory, which affect functions, such as [exec]. String cwd = Directory.current.path; @@ -347,17 +345,21 @@ Future eval( return output.toString().trimRight(); } -Future flutter(String command, { - List options = const [], - bool canFail = false, // as in, whether failures are ok. False means that they are fatal. - Map environment, -}) { - final List args = [ +List flutterCommandArgs(String command, List options) { + return [ command, if (localEngine != null) ...['--local-engine', localEngine], if (localEngineSrcPath != null) ...['--local-engine-src-path', localEngineSrcPath], ...options, ]; +} + +Future flutter(String command, { + List options = const [], + bool canFail = false, // as in, whether failures are ok. False means that they are fatal. + Map environment, +}) { + final List args = flutterCommandArgs(command, options); return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args, canFail: canFail, environment: environment); } @@ -369,12 +371,7 @@ Future evalFlutter(String command, { Map environment, StringBuffer stderr, // if not null, the stderr will be written here. }) { - final List args = [ - command, - if (localEngine != null) ...['--local-engine', localEngine], - if (localEngineSrcPath != null) ...['--local-engine-src-path', localEngineSrcPath], - ...options, - ]; + final List args = flutterCommandArgs(command, options); return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args, canFail: canFail, environment: environment, stderr: stderr); } @@ -593,39 +590,6 @@ Uri parseServiceUri(String line, { return matches.isEmpty ? null : Uri.parse(matches[0].group(0)); } -/// If FLUTTER_ENGINE environment variable is set then we need to pass -/// correct --local-engine setting too. -void setLocalEngineOptionIfNecessary(List options, [String flavor]) { - if (Platform.environment['FLUTTER_ENGINE'] != null) { - if (flavor == null) { - // If engine flavor was not specified explicitly then scan options looking - // for flags that specify the engine flavor (--release, --profile or - // --debug). Default flavor to debug if no flags were found. - const Map optionToFlavor = { - '--release': 'release', - '--debug': 'debug', - '--profile': 'profile', - }; - - for (String option in options) { - flavor = optionToFlavor[option]; - if (flavor != null) { - break; - } - } - - flavor ??= 'debug'; - } - - const Map osNames = { - DeviceOperatingSystem.ios: 'ios', - DeviceOperatingSystem.android: 'android', - }; - - options.add('--local-engine=${osNames[deviceOperatingSystem]}_$flavor'); - } -} - /// Checks that the file exists, otherwise throws a [FileSystemException]. void checkFileExists(String file) { if (!exists(File(file))) { diff --git a/dev/devicelab/lib/tasks/hot_mode_tests.dart b/dev/devicelab/lib/tasks/hot_mode_tests.dart index 1b245bfe91..28991044ba 100644 --- a/dev/devicelab/lib/tasks/hot_mode_tests.dart +++ b/dev/devicelab/lib/tasks/hot_mode_tests.dart @@ -25,7 +25,6 @@ TaskFunction createHotModeTest() { final List options = [ '--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident', ]; - setLocalEngineOptionIfNecessary(options); int hotReloadCount = 0; Map twoReloadsData; Map freshRestartReloadsData; @@ -39,7 +38,7 @@ TaskFunction createHotModeTest() { { final Process process = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: null, ); @@ -93,7 +92,7 @@ TaskFunction createHotModeTest() { { final Process process = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: null, ); final Completer stdoutDone = Completer(); diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index 8ab85cea66..88c75f49f1 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -35,7 +35,6 @@ TaskFunction createMicrobenchmarkTask() { '-d', device.deviceId, ]; - setLocalEngineOptionIfNecessary(options); options.add(benchmarkPath); return await _startFlutter( options: options, @@ -70,7 +69,7 @@ Future _startFlutter({ bool canFail = false, Map environment, }) { - final List args = ['run', ...options]; + final List args = flutterCommandArgs('run', options); return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment); } diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 2232708f76..41ac427852 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -335,7 +335,6 @@ class CompileTest { options.add('android-arm'); break; } - setLocalEngineOptionIfNecessary(options); final String compileLog = await evalFlutter('build', options: options); watch.stop(); @@ -357,7 +356,6 @@ class CompileTest { final Stopwatch watch = Stopwatch(); int releaseSizeInBytes; final List options = ['--release']; - setLocalEngineOptionIfNecessary(options); final Map metrics = {}; switch (deviceOperatingSystem) { @@ -405,7 +403,6 @@ class CompileTest { await flutter('clean'); final Stopwatch watch = Stopwatch(); final List options = ['--debug']; - setLocalEngineOptionIfNecessary(options); switch (deviceOperatingSystem) { case DeviceOperatingSystem.ios: options.insert(0, 'ios'); diff --git a/dev/devicelab/lib/tasks/run_without_leak.dart b/dev/devicelab/lib/tasks/run_without_leak.dart index b06364aac4..adb9c4d455 100644 --- a/dev/devicelab/lib/tasks/run_without_leak.dart +++ b/dev/devicelab/lib/tasks/run_without_leak.dart @@ -19,12 +19,11 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) { final List options = [ '-d', device.deviceId, '--verbose', ]; - setLocalEngineOptionIfNecessary(options); int exitCode; await inDirectory(dir, () async { final Process process = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: null, ); final Completer stdoutDone = Completer(); diff --git a/dev/devicelab/lib/tasks/web_dev_mode_tests.dart b/dev/devicelab/lib/tasks/web_dev_mode_tests.dart index dbb5e0090e..af96e095bc 100644 --- a/dev/devicelab/lib/tasks/web_dev_mode_tests.dart +++ b/dev/devicelab/lib/tasks/web_dev_mode_tests.dart @@ -19,7 +19,6 @@ TaskFunction createWebDevModeTest() { final List options = [ '--hot', '-d', 'chrome', '--verbose', '--resident', '--target=lib/main.dart', ]; - setLocalEngineOptionIfNecessary(options); int hotRestartCount = 0; await inDirectory(flutterDirectory, () async { rmTree(_editedFlutterGalleryDir); @@ -37,7 +36,7 @@ TaskFunction createWebDevModeTest() { await packagesGet.exitCode; final Process process = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: { 'FLUTTER_WEB': 'true', }, @@ -96,7 +95,7 @@ TaskFunction createWebDevModeTest() { { final Process process = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['run', ...options], + flutterCommandArgs('run', options), environment: { 'FLUTTER_WEB': 'true', },