Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: pkg/analyzer/test/src/plugin/plugin_config_test.dart

Issue 1362033002: Plugin config format validation (and tests). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/plugin/plugin_configuration.dart ('k') | pkg/analyzer/test/src/test_all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 809a1ec880e5cf9639d6fcc161fa019071899b5a..a626017a743262294ad0c8afeffd846d1578eee4 100644
--- a/pkg/analyzer/test/src/plugin/plugin_config_test.dart
+++ b/pkg/analyzer/test/src/plugin/plugin_config_test.dart
@@ -7,9 +7,10 @@ library test.src.plugin.plugin_config_test;
import 'package:analyzer/source/analysis_options_provider.dart';
import 'package:analyzer/src/plugin/plugin_configuration.dart';
import 'package:unittest/unittest.dart';
+import 'package:yaml/yaml.dart';
main() {
- group('PluginConfig', () {
+ group('plugin config tests', () {
group('parsing', () {
test('plugin map', () {
const optionsSrc = '''
@@ -36,6 +37,36 @@ analyzer:
expect(plugins[2].libraryUri, equals('myplugin/myplugin.dart'));
expect(plugins[2].className, equals('MyPlugin'));
});
+ test('plugin map (empty)', () {
+ const optionsSrc = '''
+analyzer:
+ plugins:
+ # my_plugin1: ^0.1.0 #shorthand
+''';
+ var config = parseConfig(optionsSrc);
+ // Commented out plugins shouldn't cause a parse failure.
+ expect(config.plugins.toList(), hasLength(0));
scheglov 2015/09/23 17:10:49 Do you need this toList() invocation? AFAIK hasLen
+ });
+ group('errors', () {
+ test('bad format', () {
+ const optionsSrc = '''
+analyzer:
+ plugins:
+ - my_plugin1
+ - my_plugin2
+''';
+ try {
+ parseConfig(optionsSrc);
+ fail('expected PluginConfigFormatException');
+ } on PluginConfigFormatException catch (e) {
+ expect(
+ e.message,
+ equals(
+ 'Unrecognized plugin config format (expected `YamlMap`, got `YamlList`)'));
+ expect(e.yamlNode, new isInstanceOf<YamlList>());
+ }
+ });
+ });
});
});
}
« no previous file with comments | « pkg/analyzer/lib/src/plugin/plugin_configuration.dart ('k') | pkg/analyzer/test/src/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698