diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index b2169377e1..077a9522ac 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -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 _runningProcesses = []; ProcessManager _processManager = const LocalProcessManager(); diff --git a/dev/devicelab/test/utils_test.dart b/dev/devicelab/test/utils_test.dart index d965a478dc..06db6a1d1f 100644 --- a/dev/devicelab/test/utils_test.dart +++ b/dev/devicelab/test/utils_test.dart @@ -33,4 +33,11 @@ void main() { expect(parseServicePort(badOutput), null); }); }); + + group('engine environment declarations', () { + test('localEngine', () { + expect(localEngine, null); + expect(localEngineSrcPath, null); + }); + }); }