Validate empty pubspec plugin section (#51503)

This commit is contained in:
Jenn Magder
2020-02-26 15:44:35 -08:00
committed by GitHub
parent f794091e1d
commit e31521eab5
2 changed files with 13 additions and 0 deletions

View File

@@ -177,6 +177,9 @@ class Plugin {
}
static List<String> validatePluginYaml(YamlMap yaml) {
if (yaml == null) {
return <String>['Invalid "plugin" specification.'];
}
final bool usesOldPluginFormat = const <String>{
'androidPackage',

View File

@@ -158,6 +158,16 @@ void main() {
expect(plugin.platforms, <String, PluginPlatform> {});
});
test('error on empty plugin', () {
const String pluginYamlRaw = '';
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
expect(
() => Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]),
throwsToolExit(message: 'Invalid "plugin" specification.'),
);
});
test('error on empty platforms', () {
const String pluginYamlRaw = 'platforms:\n';