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

Unified Diff: pkg/analysis_server/test/services/linter/linter_test.dart

Issue 1418333002: OptionsValidator plugin extension and linter service. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Review feedback. Created 5 years, 2 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/analysis_server/lib/src/services/linter/linter.dart ('k') | pkg/analyzer/lib/plugin/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/linter/linter_test.dart
diff --git a/pkg/analysis_server/test/services/linter/linter_test.dart b/pkg/analysis_server/test/services/linter/linter_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a1f57ebc414efabef7812b976233367e0b50719f
--- /dev/null
+++ b/pkg/analysis_server/test/services/linter/linter_test.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.services.linter;
+
+import 'package:analysis_server/src/services/linter/linter.dart';
+import 'package:analyzer/analyzer.dart';
+import 'package:analyzer/source/analysis_options_provider.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/source.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'package:unittest/unittest.dart';
+
+import '../../utils.dart';
+
+main() {
+ initializeTestEnvironment();
+ defineReflectiveTests(LinterRuleOptionsValidatorTest);
+}
+
+@reflectiveTest
+class LinterRuleOptionsValidatorTest {
+ final LinterRuleOptionsValidator validator= new LinterRuleOptionsValidator();
+ final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+
+ RecordingErrorListener recorder;
+ ErrorReporter reporter;
+
+ List<AnalysisError> get errors => recorder.errors;
+
+ setUp() {
+ recorder = new RecordingErrorListener();
+ reporter = new ErrorReporter(recorder, new _TestSource());
+ }
+
+ test_linter_defined_rules() {
+ validate(
+ '''
+linter:
+ rules:
+ - camel_case_types
+ ''',
+ []);
+ }
+
+ test_linter_no_rules() {
+ validate(
+ '''
+linter:
+ rules:
+ ''',
+ []);
+ }
+
+ test_linter_undefined_rule() {
+ validate(
+ '''
+linter:
+ rules:
+ - undefined
+ ''',
+ [UNDEFINED_LINT_WARNING]);
+ }
+
+ validate(String source, List<AnalysisOptionsErrorCode> expected) {
+ var options = optionsProvider.getOptionsFromString(source);
+ validator.validate(reporter, options);
+ expect(errors.map((AnalysisError e) => e.errorCode),
+ unorderedEquals(expected));
+ }
+}
+
+class _TestSource implements Source {
+ @override
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
« no previous file with comments | « pkg/analysis_server/lib/src/services/linter/linter.dart ('k') | pkg/analyzer/lib/plugin/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698