| 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 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/source/analysis_options_provider.dart'; | 10 import 'package:analyzer/source/analysis_options_provider.dart'; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // Apparently, duplicate error codes are allowed | 289 // Apparently, duplicate error codes are allowed |
| 290 // expect( | 290 // expect( |
| 291 // ErrorFilterOptionValidator.errorCodes.length, | 291 // ErrorFilterOptionValidator.errorCodes.length, |
| 292 // errorCodeValues.length, | 292 // errorCodeValues.length, |
| 293 // reason: 'some errorCodeValues have the same name', | 293 // reason: 'some errorCodeValues have the same name', |
| 294 // ); | 294 // ); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 @reflectiveTest | 298 @reflectiveTest |
| 299 class GenerateNewOptionsErrorsTaskTest extends GenerateOptionsErrorsTaskTest { | 299 class GenerateOldOptionsErrorsTaskTest extends AbstractContextTest { |
| 300 String get optionsFilePath => '/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; | 300 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); |
| 301 |
| 302 String get optionsFilePath => '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; |
| 303 |
| 304 test_does_analyze_old_options_files() { |
| 305 validate(''' |
| 306 analyzer: |
| 307 strong-mode: true |
| 308 ''', [AnalysisOptionsHintCode.DEPRECATED_ANALYSIS_OPTIONS_FILE_NAME]); |
| 309 } |
| 310 |
| 311 test_finds_issues_in_old_options_files() { |
| 312 validate(''' |
| 313 analyzer: |
| 314 strong_mode: true |
| 315 ''', [ |
| 316 AnalysisOptionsHintCode.DEPRECATED_ANALYSIS_OPTIONS_FILE_NAME, |
| 317 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES |
| 318 ]); |
| 319 } |
| 320 |
| 321 void validate(String content, List<ErrorCode> expected) { |
| 322 final Source source = newSource(optionsFilePath, content); |
| 323 var options = optionsProvider.getOptionsFromSource(source); |
| 324 final OptionsFileValidator validator = new OptionsFileValidator(source); |
| 325 var errors = validator.validate(options); |
| 326 expect(errors.map((AnalysisError e) => e.errorCode), |
| 327 unorderedEquals(expected)); |
| 328 } |
| 301 } | 329 } |
| 302 | 330 |
| 303 @reflectiveTest | 331 @reflectiveTest |
| 304 class GenerateOldOptionsErrorsTaskTest extends GenerateOptionsErrorsTaskTest { | 332 class GenerateNewOptionsErrorsTaskTest extends AbstractContextTest { |
| 305 String get optionsFilePath => '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; | |
| 306 } | |
| 307 | |
| 308 abstract class GenerateOptionsErrorsTaskTest extends AbstractContextTest { | |
| 309 Source source; | 333 Source source; |
| 310 | 334 |
| 311 String get optionsFilePath; | 335 String get optionsFilePath => '/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; |
| 336 |
| 312 LineInfo lineInfo(String source) => | 337 LineInfo lineInfo(String source) => |
| 313 GenerateOptionsErrorsTask.computeLineInfo(source); | 338 GenerateOptionsErrorsTask.computeLineInfo(source); |
| 314 | 339 |
| 315 @override | 340 @override |
| 316 setUp() { | 341 setUp() { |
| 317 super.setUp(); | 342 super.setUp(); |
| 318 source = newSource(optionsFilePath); | 343 source = newSource(optionsFilePath); |
| 319 } | 344 } |
| 320 | 345 |
| 321 test_buildInputs() { | 346 test_buildInputs() { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 var options = optionsProvider.getOptionsFromString(source); | 619 var options = optionsProvider.getOptionsFromString(source); |
| 595 var errors = validator.validate(options); | 620 var errors = validator.validate(options); |
| 596 expect(errors.map((AnalysisError e) => e.errorCode), | 621 expect(errors.map((AnalysisError e) => e.errorCode), |
| 597 unorderedEquals(expected)); | 622 unorderedEquals(expected)); |
| 598 } | 623 } |
| 599 } | 624 } |
| 600 | 625 |
| 601 class TestRule extends LintRule { | 626 class TestRule extends LintRule { |
| 602 TestRule() : super(name: 'fantastic_test_rule'); | 627 TestRule() : super(name: 'fantastic_test_rule'); |
| 603 } | 628 } |
| OLD | NEW |