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

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

Issue 1420363005: Error Suppression FTW. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Test fix. 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
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 test.src.task.dart_test; 5 library test.src.task.dart_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 28 matching lines...) Expand all
39 runReflectiveTests(BuildLibraryElementTaskTest); 39 runReflectiveTests(BuildLibraryElementTaskTest);
40 runReflectiveTests(BuildPublicNamespaceTaskTest); 40 runReflectiveTests(BuildPublicNamespaceTaskTest);
41 runReflectiveTests(BuildSourceExportClosureTaskTest); 41 runReflectiveTests(BuildSourceExportClosureTaskTest);
42 runReflectiveTests(BuildTypeProviderTaskTest); 42 runReflectiveTests(BuildTypeProviderTaskTest);
43 runReflectiveTests(ComputeConstantDependenciesTaskTest); 43 runReflectiveTests(ComputeConstantDependenciesTaskTest);
44 runReflectiveTests(ComputeConstantValueTaskTest); 44 runReflectiveTests(ComputeConstantValueTaskTest);
45 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); 45 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest);
46 runReflectiveTests(ComputeLibraryCycleTaskTest); 46 runReflectiveTests(ComputeLibraryCycleTaskTest);
47 runReflectiveTests(ContainingLibrariesTaskTest); 47 runReflectiveTests(ContainingLibrariesTaskTest);
48 runReflectiveTests(DartErrorsTaskTest); 48 runReflectiveTests(DartErrorsTaskTest);
49 runReflectiveTests(ErrorFilterTest);
49 runReflectiveTests(EvaluateUnitConstantsTaskTest); 50 runReflectiveTests(EvaluateUnitConstantsTaskTest);
50 runReflectiveTests(GatherUsedImportedElementsTaskTest); 51 runReflectiveTests(GatherUsedImportedElementsTaskTest);
51 runReflectiveTests(GatherUsedLocalElementsTaskTest); 52 runReflectiveTests(GatherUsedLocalElementsTaskTest);
52 runReflectiveTests(GenerateHintsTaskTest); 53 runReflectiveTests(GenerateHintsTaskTest);
53 runReflectiveTests(GenerateLintsTaskTest); 54 runReflectiveTests(GenerateLintsTaskTest);
54 runReflectiveTests(InferInstanceMembersInUnitTaskTest); 55 runReflectiveTests(InferInstanceMembersInUnitTaskTest);
55 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest); 56 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest);
56 runReflectiveTests(InferStaticVariableTypeTaskTest); 57 runReflectiveTests(InferStaticVariableTypeTaskTest);
57 runReflectiveTests(LibraryErrorsReadyTaskTest); 58 runReflectiveTests(LibraryErrorsReadyTaskTest);
58 runReflectiveTests(LibraryUnitErrorsTaskTest); 59 runReflectiveTests(LibraryUnitErrorsTaskTest);
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); 2234 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
2234 computeResult(target, HINTS, matcher: isGenerateHintsTask); 2235 computeResult(target, HINTS, matcher: isGenerateHintsTask);
2235 // validate 2236 // validate
2236 _fillErrorListener(HINTS); 2237 _fillErrorListener(HINTS);
2237 errorListener.assertErrorsWithCodes( 2238 errorListener.assertErrorsWithCodes(
2238 <ErrorCode>[HintCode.UNUSED_ELEMENT, HintCode.UNUSED_ELEMENT]); 2239 <ErrorCode>[HintCode.UNUSED_ELEMENT, HintCode.UNUSED_ELEMENT]);
2239 } 2240 }
2240 } 2241 }
2241 2242
2242 @reflectiveTest 2243 @reflectiveTest
2244 class ErrorFilterTest extends _AbstractDartTaskTest {
2245 @override
2246 setUp() {
2247 super.setUp();
2248 context.setConfigurationData(CONFIGURED_ERROR_FILTERS, [
2249 (AnalysisError error) => error.errorCode.name == 'INVALID_ASSIGNMENT'
2250 ]);
2251 }
2252
2253 test_error_filters() {
2254 AnalysisTarget library = newSource('/test.dart', '''
2255 main() {
2256 int x = ""; // INVALID_ASSIGNMENT (suppressed)
2257 // UNUSED_LOCAL_VARIABLE
2258 }''');
2259 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask);
2260 expect(outputs, hasLength(1));
2261 List<AnalysisError> errors = outputs[DART_ERRORS];
2262 expect(errors, hasLength(1));
2263 expect(errors.first.errorCode, HintCode.UNUSED_LOCAL_VARIABLE);
2264 }
2265 }
2266
2267 @reflectiveTest
2243 class GenerateLintsTaskTest extends _AbstractDartTaskTest { 2268 class GenerateLintsTaskTest extends _AbstractDartTaskTest {
2244 void enableLints() { 2269 void enableLints() {
2245 AnalysisOptionsImpl options = context.analysisOptions; 2270 AnalysisOptionsImpl options = context.analysisOptions;
2246 options.lint = true; 2271 options.lint = true;
2247 context.analysisOptions = options; 2272 context.analysisOptions = options;
2248 } 2273 }
2249 2274
2250 @override 2275 @override
2251 void setUp() { 2276 void setUp() {
2252 super.setUp(); 2277 super.setUp();
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 /** 4336 /**
4312 * Fill [errorListener] with [result] errors in the current [task]. 4337 * Fill [errorListener] with [result] errors in the current [task].
4313 */ 4338 */
4314 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4339 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4315 List<AnalysisError> errors = task.outputs[result]; 4340 List<AnalysisError> errors = task.outputs[result];
4316 expect(errors, isNotNull, reason: result.name); 4341 expect(errors, isNotNull, reason: result.name);
4317 errorListener = new GatheringErrorListener(); 4342 errorListener = new GatheringErrorListener();
4318 errorListener.addAll(errors); 4343 errorListener.addAll(errors);
4319 } 4344 }
4320 } 4345 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698