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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.services.linter;
6
7 import 'package:analysis_server/src/services/linter/linter.dart';
8 import 'package:analyzer/analyzer.dart';
9 import 'package:analyzer/source/analysis_options_provider.dart';
10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/source.dart';
12 import 'package:test_reflective_loader/test_reflective_loader.dart';
13 import 'package:unittest/unittest.dart';
14
15 import '../../utils.dart';
16
17 main() {
18 initializeTestEnvironment();
19 defineReflectiveTests(LinterRuleOptionsValidatorTest);
20 }
21
22 @reflectiveTest
23 class LinterRuleOptionsValidatorTest {
24 final LinterRuleOptionsValidator validator= new LinterRuleOptionsValidator();
25 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
26
27 RecordingErrorListener recorder;
28 ErrorReporter reporter;
29
30 List<AnalysisError> get errors => recorder.errors;
31
32 setUp() {
33 recorder = new RecordingErrorListener();
34 reporter = new ErrorReporter(recorder, new _TestSource());
35 }
36
37 test_linter_defined_rules() {
38 validate(
39 '''
40 linter:
41 rules:
42 - camel_case_types
43 ''',
44 []);
45 }
46
47 test_linter_no_rules() {
48 validate(
49 '''
50 linter:
51 rules:
52 ''',
53 []);
54 }
55
56 test_linter_undefined_rule() {
57 validate(
58 '''
59 linter:
60 rules:
61 - undefined
62 ''',
63 [UNDEFINED_LINT_WARNING]);
64 }
65
66 validate(String source, List<AnalysisOptionsErrorCode> expected) {
67 var options = optionsProvider.getOptionsFromString(source);
68 validator.validate(reporter, options);
69 expect(errors.map((AnalysisError e) => e.errorCode),
70 unorderedEquals(expected));
71 }
72 }
73
74 class _TestSource implements Source {
75 @override
76 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
77 }
OLDNEW
« 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