Commit 853c8c56 authored by Alek Åström's avatar Alek Åström Committed by Flutter GitHub Bot

[flutter_tools] Add violating plugin name to validation errors (#46601)

parent 56f4eaf5
......@@ -48,3 +48,4 @@ Rody Davis Jr <rody.davis.jr@gmail.com>
Robin Jespersen <info@unitedpartners.de>
Jefferson Quesado <jeff.quesado@gmail.com>
Mark Diener <rpzrpzrpz@gmail.com>
Alek Åström <alek.astrom@gmail.com>
......@@ -74,7 +74,7 @@ class Plugin {
) {
final List<String> errors = validatePluginYaml(pluginYaml);
if (errors.isNotEmpty) {
throwToolExit('Invalid plugin specification.\n${errors.join('\n')}');
throwToolExit('Invalid plugin specification $name.\n${errors.join('\n')}');
}
if (pluginYaml != null && pluginYaml['platforms'] != null) {
return Plugin._fromMultiPlatformYaml(name, path, pluginYaml, dependencies);
......@@ -89,11 +89,11 @@ class Plugin {
List<String> dependencies,
) {
assert (pluginYaml != null && pluginYaml['platforms'] != null,
'Invalid multi-platform plugin specification.');
'Invalid multi-platform plugin specification $name.');
final YamlMap platformsYaml = pluginYaml['platforms'] as YamlMap;
assert (_validateMultiPlatformYaml(platformsYaml).isEmpty,
'Invalid multi-platform plugin specification.');
'Invalid multi-platform plugin specification $name.');
final Map<String, PluginPlatform> platforms = <String, PluginPlatform>{};
......
......@@ -122,6 +122,19 @@ void main() {
expect(windowsPlugin.pluginClass, 'WinSamplePlugin');
});
test('Legacy Format and Multi-Platform Format together is not allowed and error message contains plugin name', () {
const String pluginYamlRaw = 'androidPackage: com.flutter.dev\n'
'platforms:\n'
' android:\n'
' package: com.flutter.dev\n';
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
expect(
() => Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]),
throwsToolExit(message: _kTestPluginName),
);
});
test('A default_package field is allowed', () {
const String pluginYamlRaw =
'platforms:\n'
......
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