Update utils.dart to work with the breaking change of SDK issue 40678 (#53093)

This commit is contained in:
Erik Ernst
2020-03-24 22:21:01 +01:00
committed by GitHub
parent 151c8db7dc
commit d99ab6aa2c
2 changed files with 23 additions and 2 deletions

View File

@@ -19,11 +19,25 @@ import 'framework.dart';
String cwd = Directory.current.path;
/// The local engine to use for [flutter] and [evalFlutter], if any.
String get localEngine => const String.fromEnvironment('localEngine');
String get localEngine {
// Use two distinct `defaultValue`s to determine whether a 'localEngine'
// declaration exists in the environment.
const bool isDefined =
String.fromEnvironment('localEngine', defaultValue: 'a') ==
String.fromEnvironment('localEngine', defaultValue: 'b');
return isDefined ? const String.fromEnvironment('localEngine') : null;
}
/// The local engine source path to use if a local engine is used for [flutter]
/// and [evalFlutter].
String get localEngineSrcPath => const String.fromEnvironment('localEngineSrcPath');
String get localEngineSrcPath {
// Use two distinct `defaultValue`s to determine whether a
// 'localEngineSrcPath' declaration exists in the environment.
const bool isDefined =
String.fromEnvironment('localEngineSrcPath', defaultValue: 'a') ==
String.fromEnvironment('localEngineSrcPath', defaultValue: 'b');
return isDefined ? const String.fromEnvironment('localEngineSrcPath') : null;
}
List<ProcessInfo> _runningProcesses = <ProcessInfo>[];
ProcessManager _processManager = const LocalProcessManager();

View File

@@ -33,4 +33,11 @@ void main() {
expect(parseServicePort(badOutput), null);
});
});
group('engine environment declarations', () {
test('localEngine', () {
expect(localEngine, null);
expect(localEngineSrcPath, null);
});
});
}