[flutter_tools] support all engine debugging options with FLUTTER_ENGINE_SWITCH environment variables (#67150)

Allow providing all debugging options to the desktop engine via the FLUTTER_ENGINE_SWITCH_ environment variables.

Fixes #66532
Fixes #46005
Fixes #58882

The underling engine changes have already landed for Windows, macOS, but linux is still in progress
This commit is contained in:
Jonah Williams
2020-10-05 09:56:48 -07:00
committed by GitHub
parent 4ce2a7aa6d
commit 21bb29cc68
2 changed files with 207 additions and 8 deletions

View File

@@ -80,7 +80,7 @@ void main() {
final Completer<void> completer = Completer<void>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['null'],
command: const <String>['debug'],
stdout: 'Observatory listening on http://127.0.0.1/0\n',
completer: completer,
),
@@ -89,7 +89,11 @@ void main() {
final String executableName = device.executablePathForDevice(null, BuildMode.debug);
fileSystem.file(executableName).writeAsStringSync('\n');
final FakeAppplicationPackage package = FakeAppplicationPackage();
final LaunchResult result = await device.startApp(package, prebuiltApplication: true);
final LaunchResult result = await device.startApp(
package,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
);
expect(result.started, true);
expect(result.observatoryUri, Uri.parse('http://127.0.0.1/0'));
@@ -99,7 +103,11 @@ void main() {
final BufferLogger logger = BufferLogger.test();
final DesktopDevice device = setUpDesktopDevice(nullExecutablePathForDevice: true, logger: logger);
final FakeAppplicationPackage package = FakeAppplicationPackage();
final LaunchResult result = await device.startApp(package, prebuiltApplication: true);
final LaunchResult result = await device.startApp(
package,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
);
expect(result.started, false);
expect(logger.errorText, contains('Unable to find executable to run'));
@@ -109,20 +117,123 @@ void main() {
final Completer<void> completer = Completer<void>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['null'],
command: const <String>['debug'],
stdout: 'Observatory listening on http://127.0.0.1/0\n',
completer: completer,
),
]);
final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager);
final FakeAppplicationPackage package = FakeAppplicationPackage();
final LaunchResult result = await device.startApp(package, prebuiltApplication: true);
final LaunchResult result = await device.startApp(
package,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
);
expect(result.started, true);
expect(await device.stopApp(package), true);
});
});
testWithoutContext('startApp supports DebuggingOptions through FLUTTER_ENGINE_SWITCH environment variables', () async {
final Completer<void> completer = Completer<void>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['debug'],
stdout: 'Observatory listening on http://127.0.0.1/0\n',
completer: completer,
environment: const <String, String>{
'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true',
'FLUTTER_ENGINE_SWITCH_2': 'enable-background-compilation=true',
'FLUTTER_ENGINE_SWITCH_3': 'trace-startup=true',
'FLUTTER_ENGINE_SWITCH_4': 'enable-software-rendering=true',
'FLUTTER_ENGINE_SWITCH_5': 'skia-deterministic-rendering=true',
'FLUTTER_ENGINE_SWITCH_6': 'trace-skia=true',
'FLUTTER_ENGINE_SWITCH_7': 'trace-allowlist=foo,bar',
'FLUTTER_ENGINE_SWITCH_8': 'trace-systrace=true',
'FLUTTER_ENGINE_SWITCH_9': 'endless-trace-buffer=true',
'FLUTTER_ENGINE_SWITCH_10': 'dump-skp-on-shader-compilation=true',
'FLUTTER_ENGINE_SWITCH_11': 'cache-sksl=true',
'FLUTTER_ENGINE_SWITCH_12': 'purge-persistent-cache=true',
'FLUTTER_ENGINE_SWITCH_13': 'enable-checked-mode=true',
'FLUTTER_ENGINE_SWITCH_14': 'verify-entry-points=true',
'FLUTTER_ENGINE_SWITCH_15': 'start-paused=true',
'FLUTTER_ENGINE_SWITCH_16': 'disable-service-auth-codes=true',
'FLUTTER_ENGINE_SWITCH_17': 'dart-flags=--null_assertions',
'FLUTTER_ENGINE_SWITCH_18': 'use-test-fonts=true',
'FLUTTER_ENGINE_SWITCH_19': 'verbose-logging=true',
'FLUTTER_ENGINE_SWITCHES': '19'
}
),
]);
final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager);
final FakeAppplicationPackage package = FakeAppplicationPackage();
final LaunchResult result = await device.startApp(
package,
prebuiltApplication: true,
platformArgs: <String, Object>{
'trace-startup': true,
},
debuggingOptions: DebuggingOptions.enabled(
BuildInfo.debug,
startPaused: true,
disableServiceAuthCodes: true,
dartFlags: '',
enableSoftwareRendering: true,
skiaDeterministicRendering: true,
traceSkia: true,
traceAllowlist: 'foo,bar',
traceSystrace: true,
endlessTraceBuffer: true,
dumpSkpOnShaderCompilation: true,
cacheSkSL: true,
purgePersistentCache: true,
useTestFonts: true,
verboseSystemLogs: true,
initializePlatform: true,
nullAssertions: true,
),
);
expect(result.started, true);
});
testWithoutContext('startApp supports DebuggingOptions through FLUTTER_ENGINE_SWITCH environment variables when debugging is disabled', () async {
final Completer<void> completer = Completer<void>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['debug'],
stdout: 'Observatory listening on http://127.0.0.1/0\n',
completer: completer,
environment: const <String, String>{
'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true',
'FLUTTER_ENGINE_SWITCH_2': 'enable-background-compilation=true',
'FLUTTER_ENGINE_SWITCH_3': 'trace-startup=true',
'FLUTTER_ENGINE_SWITCH_4': 'trace-allowlist=foo,bar',
'FLUTTER_ENGINE_SWITCH_5': 'cache-sksl=true',
'FLUTTER_ENGINE_SWITCHES': '5'
}
),
]);
final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager);
final FakeAppplicationPackage package = FakeAppplicationPackage();
final LaunchResult result = await device.startApp(
package,
prebuiltApplication: true,
platformArgs: <String, Object>{
'trace-startup': true,
},
debuggingOptions: DebuggingOptions.disabled(
BuildInfo.debug,
traceAllowlist: 'foo,bar',
cacheSkSL: true,
initializePlatform: true,
),
);
expect(result.started, true);
});
testWithoutContext('Port forwarder is a no-op', () async {
final FakeDesktopDevice device = setUpDesktopDevice();
final DevicePortForwarder portForwarder = device.portForwarder;