Unverified Commit 63ba1b23 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add support for --bundle-sksl-path to `flutter run` / `flutter drive` (#80885)

parent 5d37df13
......@@ -823,7 +823,7 @@ class PerfTestWithSkSL extends PerfTest {
await _generateSkSL();
// Build the app with SkSL artifacts and run that app
final String observatoryUri = await _buildAndRun();
final String observatoryUri = await _runApp(skslPath: _skslJsonFileName);
// Attach to the running app and run the final driver test to get metrics.
final TaskResult result = await internalRun(
......@@ -859,7 +859,7 @@ class PerfTestWithSkSL extends PerfTest {
);
}
Future<String> _runApp({String appBinary, bool cacheSkSL = false}) async {
Future<String> _runApp({String appBinary, bool cacheSkSL = false, String skslPath}) async {
if (File(_vmserviceFileName).existsSync()) {
File(_vmserviceFileName).deleteSync();
}
......@@ -877,6 +877,7 @@ class PerfTestWithSkSL extends PerfTest {
'--purge-persistent-cache',
'--no-publish-port',
'--profile',
if (skslPath != null) '--bundle-sksl-path=$skslPath',
if (cacheSkSL) '--cache-sksl',
'-d', _device.deviceId,
'-t', testTarget,
......@@ -894,18 +895,6 @@ class PerfTestWithSkSL extends PerfTest {
return file.readAsStringSync();
}
// Return the VMService URI.
Future<String> _buildAndRun() async {
await flutter('build', options: <String>[
if (_isAndroid) 'apk' else 'ios',
'--profile',
'--bundle-sksl-path', _skslJsonFileName,
'-t', testTarget,
]);
return _runApp(appBinary: _appBinary);
}
String get _skslJsonFileName => '$testDirectory/flutter_01.sksl.json';
String get _vmserviceFileName => '$testDirectory/$_kVmserviceOutFileName';
......
......@@ -36,6 +36,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
usesFlavorOption();
usesWebRendererOption();
addNativeNullAssertions(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
argParser
..addFlag('trace-startup',
negatable: false,
......
......@@ -507,6 +507,16 @@ void main() {
'--no-pub',
]), throwsA(isA<RPCError>()));
});
testUsingContext('Passes sksl bundle info the build options', () async {
final TestRunCommandWithFakeResidentRunner command = TestRunCommandWithFakeResidentRunner();
await expectLater(() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--bundle-sksl-path=foo.json',
]), throwsA(isA<ToolExit>().having((ToolExit exit) => exit.message, 'message', contains('No SkSL shader bundle found at foo.json'))));
});
}
class MockCache extends Mock implements Cache {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment