Unverified Commit 16df32b1 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] handle invalid yaml in plugin dependency (#63526)

parent 8dcb4c33
......@@ -311,7 +311,14 @@ Plugin _pluginFromPackage(String name, Uri packageRoot) {
if (!globals.fs.isFileSync(pubspecPath)) {
return null;
}
final dynamic pubspec = loadYaml(globals.fs.file(pubspecPath).readAsStringSync());
dynamic pubspec;
try {
pubspec = loadYaml(globals.fs.file(pubspecPath).readAsStringSync());
} on YamlException catch (err) {
globals.printTrace('Failed to parse plugin manifest for $name: $err');
// Do nothing, potentially not a plugin.
}
if (pubspec == null) {
return null;
}
......
......@@ -908,6 +908,28 @@ flutter:
FeatureFlags: () => featureFlags,
});
testUsingContext('Invalid yaml does not crash plugin lookup.', () async {
when(macosProject.existsSync()).thenReturn(true);
when(featureFlags.isMacOSEnabled).thenReturn(true);
when(flutterProject.isModule).thenReturn(true);
// Create a plugin without a pluginClass.
dummyPackageDirectory.parent.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(r'''
"aws ... \"Branch\": $BITBUCKET_BRANCH, \"Date\": $(date +"%m-%d-%y"), \"Time\": $(date +"%T")}\"
''');
await injectPlugins(flutterProject, checkProjects: true);
final File registrantFile = macosProject.managedDirectory.childFile('GeneratedPluginRegistrant.swift');
expect(registrantFile, exists);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => featureFlags,
});
testUsingContext('Injecting creates generated Linux registrant', () async {
when(linuxProject.existsSync()).thenReturn(true);
when(featureFlags.isLinuxEnabled).thenReturn(true);
......
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