Index: pkg/analyzer/test/src/plugin/plugin_config_test.dart |
diff --git a/pkg/analyzer/test/src/plugin/plugin_config_test.dart b/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
index e3cc9603fc82d2d0043767917fd7d0fd4c56e6df..4f89cb34c2cbe45335fc95ed81639a342dbc6eb9 100644 |
--- a/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
+++ b/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
@@ -25,7 +25,7 @@ analyzer: |
path: '/u/disk/src/' |
'''; |
var config = parseConfig(optionsSrc); |
- var plugins = pluginsSortedByName(config); |
+ var plugins = pluginsSortedByName(config.plugins); |
expect(plugins, hasLength(3)); |
expect(plugins[0].name, equals('my_plugin1')); |
expect(plugins[0].version, equals('^0.1.0')); |
@@ -47,8 +47,26 @@ analyzer: |
// Commented out plugins shouldn't cause a parse failure. |
expect(config.plugins, hasLength(0)); |
}); |
+ test('plugin manifest', () { |
+ const manifestSrc = ''' |
+analyzer-plugin: |
+ class_name: AnalyzerPlugin |
+ library_uri: myplugin/analyzer_plugin.dart |
+server-plugin: |
+ class_name: ServerPlugin |
+ library_uri: myplugin/server_plugin.dart |
+'''; |
+ var manifest = parsePluginManifestString(manifestSrc); |
+ var analyzerPlugin = manifest.analyzerPlugin; |
+ expect( |
+ analyzerPlugin.libraryUri, equals('myplugin/analyzer_plugin.dart')); |
+ expect(analyzerPlugin.className, equals('AnalyzerPlugin')); |
+ var serverPlugin = manifest.serverPlugin; |
+ expect(serverPlugin.libraryUri, equals('myplugin/server_plugin.dart')); |
+ expect(serverPlugin.className, equals('ServerPlugin')); |
+ }); |
group('errors', () { |
- test('bad format', () { |
+ test('bad config format', () { |
const optionsSrc = ''' |
analyzer: |
plugins: |
@@ -62,7 +80,23 @@ analyzer: |
expect( |
e.message, |
equals( |
- 'Unrecognized plugin config format (expected `YamlMap`, got `YamlList`)')); |
+ 'Unrecognized plugin config format, expected `YamlMap`, got `YamlList`')); |
+ expect(e.yamlNode, new isInstanceOf<YamlList>()); |
+ } |
+ }); |
+ test('bad manifest format', () { |
+ const manifestSource = ''' |
+analyzer-plugin: |
+ - Foo |
+'''; |
+ try { |
+ parsePluginManifestString(manifestSource); |
+ fail('expected PluginConfigFormatException'); |
+ } on PluginConfigFormatException catch (e) { |
+ expect( |
+ e.message, |
+ equals( |
+ 'Unable to parse plugin manifest, expected `YamlMap`, got `YamlList`')); |
expect(e.yamlNode, new isInstanceOf<YamlList>()); |
} |
}); |
@@ -76,5 +110,5 @@ PluginConfig parseConfig(String optionsSrc) { |
return new PluginConfig.fromOptions(options); |
} |
-List<PluginInfo> pluginsSortedByName(PluginConfig config) => |
- config.plugins.toList()..sort((p1, p2) => p1.name.compareTo(p2.name)); |
+List<PluginInfo> pluginsSortedByName(Iterable<PluginInfo> plugins) => |
+ plugins.toList()..sort((p1, p2) => p1.name.compareTo(p2.name)); |