Enable dump-skp-on-shader-compilation in drive (#43022)

This commit is contained in:
liyuqian
2019-10-24 11:04:59 -07:00
committed by Jonah Williams
parent c1d3ca07fe
commit 4f385c8fb7
3 changed files with 120 additions and 9 deletions

View File

@@ -459,6 +459,114 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
});
group('debugging options', () {
DebuggingOptions debuggingOptions;
String testApp, testFile;
setUp(() {
restoreAppStarter();
});
Future<void> appStarterSetup() async {
mockDevice = MockDevice();
testDeviceManager.addDevice(mockDevice);
final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader();
when(mockDevice.getLogReader()).thenReturn(mockDeviceLogReader);
final MockLaunchResult mockLaunchResult = MockLaunchResult();
when(mockLaunchResult.started).thenReturn(true);
when(mockDevice.startApp(
null,
mainPath: anyNamed('mainPath'),
route: anyNamed('route'),
debuggingOptions: anyNamed('debuggingOptions'),
platformArgs: anyNamed('platformArgs'),
prebuiltApplication: anyNamed('prebuiltApplication'),
)).thenAnswer((Invocation invocation) async {
debuggingOptions = invocation.namedArguments[#debuggingOptions];
return mockLaunchResult;
});
when(mockDevice.isAppInstalled(any))
.thenAnswer((_) => Future<bool>.value(false));
testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
testRunner = (List<String> testArgs, String observatoryUri) async {
throwToolExit(null, exitCode: 123);
};
appStopper = expectAsync1(
(DriveCommand command) async {
return true;
},
count: 2,
);
final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() {}');
await memFs.file(testFile).writeAsString('main() {}');
}
void _testOptionThatDefaultsToFalse(
String optionName,
bool setToTrue,
bool optionValue(),
) {
testUsingContext('$optionName ${setToTrue ? 'works' : 'defaults to false'}', () async {
await appStarterSetup();
final List<String> args = <String>[
'drive',
'--target=$testApp',
if (setToTrue) optionName,
'--no-pub',
];
try {
await createTestCommandRunner(command).run(args);
} on ToolExit catch (e) {
expect(e.exitCode, 123);
expect(e.message, null);
}
verify(mockDevice.startApp(
null,
mainPath: anyNamed('mainPath'),
route: anyNamed('route'),
debuggingOptions: anyNamed('debuggingOptions'),
platformArgs: anyNamed('platformArgs'),
prebuiltApplication: false,
));
expect(optionValue(), setToTrue ? isTrue : isFalse);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager(<FakeCommand>[]),
});
}
void testOptionThatDefaultsToFalse(
String optionName,
bool optionValue(),
) {
_testOptionThatDefaultsToFalse(optionName, true, optionValue);
_testOptionThatDefaultsToFalse(optionName, false, optionValue);
}
testOptionThatDefaultsToFalse(
'--dump-skp-on-shader-compilation',
() => debuggingOptions.dumpSkpOnShaderCompilation,
);
testOptionThatDefaultsToFalse(
'--verbose-system-logs',
() => debuggingOptions.verboseSystemLogs,
);
testOptionThatDefaultsToFalse(
'--cache-sksl',
() => debuggingOptions.cacheSkSL,
);
});
});
}