From d99ab6aa2c20b99ee0ae29081cb6984d9d805f66 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Tue, 24 Mar 2020 22:21:01 +0100 Subject: [PATCH] Update utils.dart to work with the breaking change of SDK issue 40678 (#53093) --- dev/devicelab/lib/framework/utils.dart | 18 ++++++++++++++++-- dev/devicelab/test/utils_test.dart | 7 +++++++ 2 files changed, 23 insertions(+), 2 deletions(-) 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); + }); + }); }