| OLD | NEW |
| 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/source/error_processor.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 isInstanceOf isGenerateOptionsErrorsTask = | 31 isInstanceOf isGenerateOptionsErrorsTask = |
| 32 new isInstanceOf<GenerateOptionsErrorsTask>(); | 32 new isInstanceOf<GenerateOptionsErrorsTask>(); |
| 33 | 33 |
| 34 @reflectiveTest | 34 @reflectiveTest |
| 35 class ContextConfigurationTest extends AbstractContextTest { | 35 class ContextConfigurationTest extends AbstractContextTest { |
| 36 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); | 36 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); |
| 37 | 37 |
| 38 AnalysisOptions get analysisOptions => context.analysisOptions; | 38 AnalysisOptions get analysisOptions => context.analysisOptions; |
| 39 | 39 |
| 40 configureContext(String optionsSource) => | 40 configureContext(String optionsSource) => |
| 41 configureContextOptions(context, parseOptions(optionsSource)); | 41 applyToAnalysisOptions(analysisOptions, parseOptions(optionsSource)); |
| 42 | 42 |
| 43 Map<String, YamlNode> parseOptions(String source) => | 43 Map<String, YamlNode> parseOptions(String source) => |
| 44 optionsProvider.getOptionsFromString(source); | 44 optionsProvider.getOptionsFromString(source); |
| 45 | 45 |
| 46 test_configure_bad_options_contents() { | 46 test_configure_bad_options_contents() { |
| 47 configureContext(''' | 47 configureContext(''' |
| 48 analyzer: | 48 analyzer: |
| 49 strong-mode:true # misformatted | 49 strong-mode:true # misformatted |
| 50 '''); | 50 '''); |
| 51 expect(analysisOptions.strongMode, false); | 51 expect(analysisOptions.strongMode, false); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 test_configure_error_processors() { | 82 test_configure_error_processors() { |
| 83 configureContext(''' | 83 configureContext(''' |
| 84 analyzer: | 84 analyzer: |
| 85 errors: | 85 errors: |
| 86 invalid_assignment: ignore | 86 invalid_assignment: ignore |
| 87 unused_local_variable: error | 87 unused_local_variable: error |
| 88 '''); | 88 '''); |
| 89 | 89 |
| 90 List<ErrorProcessor> processors = context.analysisOptions.errorProcessors; | 90 List<ErrorProcessor> processors = analysisOptions.errorProcessors; |
| 91 expect(processors, hasLength(2)); | 91 expect(processors, hasLength(2)); |
| 92 | 92 |
| 93 var unused_local = new AnalysisError( | 93 var unused_local = new AnalysisError( |
| 94 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ | 94 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ |
| 95 ['x'] | 95 ['x'] |
| 96 ]); | 96 ]); |
| 97 var invalid_assignment = | 97 var invalid_assignment = |
| 98 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [ | 98 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [ |
| 99 ['x'], | 99 ['x'], |
| 100 ['y'] | 100 ['y'] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 test_configure_excludes() { | 113 test_configure_excludes() { |
| 114 configureContext(''' | 114 configureContext(''' |
| 115 analyzer: | 115 analyzer: |
| 116 exclude: | 116 exclude: |
| 117 - foo/bar.dart | 117 - foo/bar.dart |
| 118 - 'test/**' | 118 - 'test/**' |
| 119 '''); | 119 '''); |
| 120 | 120 |
| 121 List<String> excludes = context.analysisOptions.excludePatterns; | 121 List<String> excludes = analysisOptions.excludePatterns; |
| 122 expect(excludes, unorderedEquals(['foo/bar.dart', 'test/**'])); | 122 expect(excludes, unorderedEquals(['foo/bar.dart', 'test/**'])); |
| 123 } | 123 } |
| 124 | 124 |
| 125 test_configure_strong_mode() { | 125 test_configure_strong_mode() { |
| 126 configureContext(''' | 126 configureContext(''' |
| 127 analyzer: | 127 analyzer: |
| 128 strong-mode: true | 128 strong-mode: true |
| 129 '''); | 129 '''); |
| 130 expect(analysisOptions.strongMode, true); | 130 expect(analysisOptions.strongMode, true); |
| 131 } | 131 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); | 461 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void validate(String source, List<ErrorCode> expected) { | 464 void validate(String source, List<ErrorCode> expected) { |
| 465 var options = optionsProvider.getOptionsFromString(source); | 465 var options = optionsProvider.getOptionsFromString(source); |
| 466 var errors = validator.validate(options); | 466 var errors = validator.validate(options); |
| 467 expect(errors.map((AnalysisError e) => e.errorCode), | 467 expect(errors.map((AnalysisError e) => e.errorCode), |
| 468 unorderedEquals(expected)); | 468 unorderedEquals(expected)); |
| 469 } | 469 } |
| 470 } | 470 } |
| OLD | NEW |