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

Side by Side Diff: pkg/analyzer/test/src/task/options_test.dart

Issue 1517723002: Server custom error severity support (#24452). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: lib_renames Created 5 years 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
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.task.options_test; 5 library analyzer.test.src.task.options_test;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/source/analysis_options_provider.dart'; 8 import 'package:analyzer/source/analysis_options_provider.dart';
9 import 'package:analyzer/source/error_processor.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
11 import 'package:analyzer/src/task/options.dart'; 12 import 'package:analyzer/src/task/options.dart';
12 import 'package:analyzer/task/general.dart'; 13 import 'package:analyzer/task/general.dart';
13 import 'package:analyzer/task/model.dart'; 14 import 'package:analyzer/task/model.dart';
14 import 'package:unittest/unittest.dart'; 15 import 'package:unittest/unittest.dart';
15 import 'package:yaml/yaml.dart'; 16 import 'package:yaml/yaml.dart';
16 17
17 import '../../generated/test_support.dart'; 18 import '../../generated/test_support.dart';
18 import '../../reflective_tests.dart'; 19 import '../../reflective_tests.dart';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 62
62 test_configure_enableSuperMixins() { 63 test_configure_enableSuperMixins() {
63 configureContext(''' 64 configureContext('''
64 analyzer: 65 analyzer:
65 language: 66 language:
66 enableSuperMixins: true 67 enableSuperMixins: true
67 '''); 68 ''');
68 expect(analysisOptions.enableSuperMixins, true); 69 expect(analysisOptions.enableSuperMixins, true);
69 } 70 }
70 71
71 test_configure_error_filters() { 72 test_configure_error_processors() {
72 configureContext(''' 73 configureContext('''
73 analyzer: 74 analyzer:
74 errors: 75 errors:
75 invalid_assignment: ignore 76 invalid_assignment: ignore
76 unused_local_variable: ignore 77 unused_local_variable: error
77 '''); 78 ''');
78 79
79 List<ErrorFilter> filters = 80 List<ErrorProcessor> processors =
80 context.getConfigurationData(CONFIGURED_ERROR_FILTERS); 81 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS);
81 expect(filters, hasLength(2)); 82 expect(processors, hasLength(2));
82 83
83 var unused_error = new AnalysisError( 84 var unused_local = new AnalysisError(
84 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ 85 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
85 ['x'] 86 ['x']
86 ]); 87 ]);
87 var invalid_assignment_error = 88 var invalid_assignment =
88 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [ 89 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [
89 ['x'], 90 ['x'],
90 ['y'] 91 ['y']
91 ]); 92 ]);
92 93
93 expect(filters.any((filter) => filter(unused_error)), isTrue); 94 // ignore
94 expect(filters.any((filter) => filter(invalid_assignment_error)), isTrue); 95 var invalidAssignment =
96 processors.firstWhere((p) => p.appliesTo(invalid_assignment));
97 expect(invalidAssignment.severity, isNull);
98
99 // error
100 var unusedLocal = processors.firstWhere((p) => p.appliesTo(unused_local));
101 expect(unusedLocal.severity, ErrorSeverity.ERROR);
95 } 102 }
96 103
97 test_configure_strong_mode() { 104 test_configure_strong_mode() {
98 configureContext(''' 105 configureContext('''
99 analyzer: 106 analyzer:
100 strong-mode: true 107 strong-mode: true
101 '''); 108 ''');
102 expect(analysisOptions.strongMode, true); 109 expect(analysisOptions.strongMode, true);
103 } 110 }
104 111
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); 357 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
351 } 358 }
352 359
353 void validate(String source, List<AnalysisOptionsErrorCode> expected) { 360 void validate(String source, List<AnalysisOptionsErrorCode> expected) {
354 var options = optionsProvider.getOptionsFromString(source); 361 var options = optionsProvider.getOptionsFromString(source);
355 var errors = validator.validate(options); 362 var errors = validator.validate(options);
356 expect(errors.map((AnalysisError e) => e.errorCode), 363 expect(errors.map((AnalysisError e) => e.errorCode),
357 unorderedEquals(expected)); 364 unorderedEquals(expected));
358 } 365 }
359 } 366 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698