[flutter_tools] Add violating plugin name to validation errors (#46601)
This commit is contained in:
parent
56f4eaf58c
commit
853c8c569f
1
AUTHORS
1
AUTHORS
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user