Unverified Commit ac614de7 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] validate that SkSL bundle path exists (#67883)

Fixes #61772

tool exit if there is no file at the path provided when building/running with sksl
parent fd11d149
...@@ -775,6 +775,10 @@ abstract class FlutterCommand extends Command<void> { ...@@ -775,6 +775,10 @@ abstract class FlutterCommand extends Command<void> {
? stringArg(FlutterOptions.kBundleSkSLPathOption) ? stringArg(FlutterOptions.kBundleSkSLPathOption)
: null; : null;
if (bundleSkSLPath != null && !globals.fs.isFileSync(bundleSkSLPath)) {
throwToolExit('No SkSL shader bundle found at $bundleSkSLPath.');
}
final String performanceMeasurementFile = argParser.options.containsKey(FlutterOptions.kPerformanceMeasurementFile) final String performanceMeasurementFile = argParser.options.containsKey(FlutterOptions.kPerformanceMeasurementFile)
? stringArg(FlutterOptions.kPerformanceMeasurementFile) ? stringArg(FlutterOptions.kPerformanceMeasurementFile)
: null; : null;
......
...@@ -279,6 +279,8 @@ void main() { ...@@ -279,6 +279,8 @@ void main() {
]); ]);
fileSystem.file('lib/other.dart') fileSystem.file('lib/other.dart')
.createSync(recursive: true); .createSync(recursive: true);
fileSystem.file('foo/bar.sksl.json')
.createSync(recursive: true);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>[ const <String>[
......
...@@ -229,6 +229,8 @@ void main() { ...@@ -229,6 +229,8 @@ void main() {
createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
fileSystem.file('lib/other.dart') fileSystem.file('lib/other.dart')
.createSync(recursive: true); .createSync(recursive: true);
fileSystem.file('foo/bar.sksl.json')
.createSync(recursive: true);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>[ const <String>[
......
...@@ -286,6 +286,8 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier ...@@ -286,6 +286,8 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
]); ]);
fileSystem.file(fileSystem.path.join('lib', 'other.dart')) fileSystem.file(fileSystem.path.join('lib', 'other.dart'))
.createSync(recursive: true); .createSync(recursive: true);
fileSystem.file(fileSystem.path.join('foo', 'bar.sksl.json'))
.createSync(recursive: true);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>[ const <String>[
......
...@@ -185,18 +185,17 @@ void main() { ...@@ -185,18 +185,17 @@ void main() {
}); });
testWithoutContext('will load bootstrap script before starting', () async { testWithoutContext('will load bootstrap script before starting', () async {
final String flutterBin = final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final File bootstrap = fileSystem.file(fileSystem.path.join( final File bootstrap = fileSystem.file(fileSystem.path.join(
getFlutterRoot(), getFlutterRoot(),
'bin', 'bin',
'internal', 'internal',
platform.isWindows ? 'bootstrap.bat' : 'bootstrap.sh')); platform.isWindows ? 'bootstrap.bat' : 'bootstrap.sh'),
);
try { try {
bootstrap.writeAsStringSync('echo TESTING 1 2 3'); bootstrap.writeAsStringSync('echo TESTING 1 2 3');
final ProcessResult result = await processManager.run(<String>[ final ProcessResult result = await processManager.run(<String>[
flutterBin, flutterBin,
...getLocalEngineArguments(), ...getLocalEngineArguments(),
...@@ -207,4 +206,19 @@ void main() { ...@@ -207,4 +206,19 @@ void main() {
bootstrap.deleteSync(); bootstrap.deleteSync();
} }
}); });
testWithoutContext('Providing sksl bundle with missing file with tool exit', () async {
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final String helloWorld = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
final ProcessResult result = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'apk',
'--bundle-sksl-path=foo/bar/baz.json', // This file does not exist.
], workingDirectory: helloWorld);
expect(result.exitCode, 1);
expect(result.stderr, contains('No SkSL shader bundle found at foo/bar/baz.json'));
});
} }
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