devicelab: replace the FLUTTER_ENGINE environment variable with the new local engine flags (#36969)
This commit is contained in:
@@ -36,11 +36,10 @@ Future<TaskResult> createFlutterRunTask() async {
|
||||
final List<String> options = <String>[
|
||||
'-t', runTestSource.absolute.path, '-d', device.deviceId,
|
||||
];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
await inDirectory<void>(flutterGalleryDir, () async {
|
||||
startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> finished = Completer<void>();
|
||||
|
||||
@@ -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<String> eval(
|
||||
return output.toString().trimRight();
|
||||
}
|
||||
|
||||
Future<int> flutter(String command, {
|
||||
List<String> options = const <String>[],
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
final List<String> args = <String>[
|
||||
List<String> flutterCommandArgs(String command, List<String> options) {
|
||||
return <String>[
|
||||
command,
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
|
||||
...options,
|
||||
];
|
||||
}
|
||||
|
||||
Future<int> flutter(String command, {
|
||||
List<String> options = const <String>[],
|
||||
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
final List<String> args = flutterCommandArgs(command, options);
|
||||
return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment);
|
||||
}
|
||||
@@ -369,12 +371,7 @@ Future<String> evalFlutter(String command, {
|
||||
Map<String, String> environment,
|
||||
StringBuffer stderr, // if not null, the stderr will be written here.
|
||||
}) {
|
||||
final List<String> args = <String>[
|
||||
command,
|
||||
if (localEngine != null) ...<String>['--local-engine', localEngine],
|
||||
if (localEngineSrcPath != null) ...<String>['--local-engine-src-path', localEngineSrcPath],
|
||||
...options,
|
||||
];
|
||||
final List<String> 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<String> 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<String, String> optionToFlavor = <String, String>{
|
||||
'--release': 'release',
|
||||
'--debug': 'debug',
|
||||
'--profile': 'profile',
|
||||
};
|
||||
|
||||
for (String option in options) {
|
||||
flavor = optionToFlavor[option];
|
||||
if (flavor != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
flavor ??= 'debug';
|
||||
}
|
||||
|
||||
const Map<DeviceOperatingSystem, String> osNames = <DeviceOperatingSystem, String>{
|
||||
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))) {
|
||||
|
||||
@@ -25,7 +25,6 @@ TaskFunction createHotModeTest() {
|
||||
final List<String> options = <String>[
|
||||
'--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident',
|
||||
];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
int hotReloadCount = 0;
|
||||
Map<String, dynamic> twoReloadsData;
|
||||
Map<String, dynamic> freshRestartReloadsData;
|
||||
@@ -39,7 +38,7 @@ TaskFunction createHotModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: null,
|
||||
);
|
||||
|
||||
@@ -93,7 +92,7 @@ TaskFunction createHotModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
|
||||
@@ -35,7 +35,6 @@ TaskFunction createMicrobenchmarkTask() {
|
||||
'-d',
|
||||
device.deviceId,
|
||||
];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
options.add(benchmarkPath);
|
||||
return await _startFlutter(
|
||||
options: options,
|
||||
@@ -70,7 +69,7 @@ Future<Process> _startFlutter({
|
||||
bool canFail = false,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
final List<String> args = <String>['run', ...options];
|
||||
final List<String> args = flutterCommandArgs('run', options);
|
||||
return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String> options = <String>['--release'];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
final Map<String, dynamic> metrics = <String, dynamic>{};
|
||||
|
||||
switch (deviceOperatingSystem) {
|
||||
@@ -405,7 +403,6 @@ class CompileTest {
|
||||
await flutter('clean');
|
||||
final Stopwatch watch = Stopwatch();
|
||||
final List<String> options = <String>['--debug'];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
switch (deviceOperatingSystem) {
|
||||
case DeviceOperatingSystem.ios:
|
||||
options.insert(0, 'ios');
|
||||
|
||||
@@ -19,12 +19,11 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) {
|
||||
final List<String> options = <String>[
|
||||
'-d', device.deviceId, '--verbose',
|
||||
];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
int exitCode;
|
||||
await inDirectory<void>(dir, () async {
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
|
||||
@@ -19,7 +19,6 @@ TaskFunction createWebDevModeTest() {
|
||||
final List<String> options = <String>[
|
||||
'--hot', '-d', 'chrome', '--verbose', '--resident', '--target=lib/main.dart',
|
||||
];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
int hotRestartCount = 0;
|
||||
await inDirectory<void>(flutterDirectory, () async {
|
||||
rmTree(_editedFlutterGalleryDir);
|
||||
@@ -37,7 +36,7 @@ TaskFunction createWebDevModeTest() {
|
||||
await packagesGet.exitCode;
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
@@ -96,7 +95,7 @@ TaskFunction createWebDevModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
flutterCommandArgs('run', options),
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user