| 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'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:analyzer/src/lint/linter.dart'; |
| 13 import 'package:analyzer/src/lint/registry.dart'; |
| 12 import 'package:analyzer/src/task/options.dart'; | 14 import 'package:analyzer/src/task/options.dart'; |
| 13 import 'package:analyzer/task/general.dart'; | 15 import 'package:analyzer/task/general.dart'; |
| 14 import 'package:analyzer/task/model.dart'; | 16 import 'package:analyzer/task/model.dart'; |
| 15 import 'package:linter/src/rules.dart'; | |
| 16 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
| 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 18 import 'package:yaml/yaml.dart'; | 19 import 'package:yaml/yaml.dart'; |
| 19 | 20 |
| 20 import '../../generated/test_support.dart'; | 21 import '../../generated/test_support.dart'; |
| 21 import '../context/abstract_context.dart'; | 22 import '../context/abstract_context.dart'; |
| 22 | 23 |
| 23 main() { | 24 main() { |
| 24 defineReflectiveSuite(() { | 25 defineReflectiveSuite(() { |
| 25 defineReflectiveTests(ContextConfigurationTest); | 26 defineReflectiveTests(ContextConfigurationTest); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 test_analyzer_unsupported_option() { | 438 test_analyzer_unsupported_option() { |
| 438 validate( | 439 validate( |
| 439 ''' | 440 ''' |
| 440 analyzer: | 441 analyzer: |
| 441 not_supported: true | 442 not_supported: true |
| 442 ''', | 443 ''', |
| 443 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES]); | 444 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES]); |
| 444 } | 445 } |
| 445 | 446 |
| 446 test_linter_supported_rules() { | 447 test_linter_supported_rules() { |
| 447 registerLintRules(); | 448 Registry.ruleRegistry.register(new TestRule()); |
| 448 validate( | 449 validate( |
| 449 ''' | 450 ''' |
| 450 linter: | 451 linter: |
| 451 rules: | 452 rules: |
| 452 - camel_case_types | 453 - fantastic_test_rule |
| 453 ''', | 454 ''', |
| 454 []); | 455 []); |
| 455 } | 456 } |
| 456 | 457 |
| 457 test_linter_unsupported_option() { | 458 test_linter_unsupported_option() { |
| 458 validate( | 459 validate( |
| 459 ''' | 460 ''' |
| 460 linter: | 461 linter: |
| 461 unsupported: true | 462 unsupported: true |
| 462 ''', | 463 ''', |
| 463 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); | 464 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); |
| 464 } | 465 } |
| 465 | 466 |
| 466 void validate(String source, List<ErrorCode> expected) { | 467 void validate(String source, List<ErrorCode> expected) { |
| 467 var options = optionsProvider.getOptionsFromString(source); | 468 var options = optionsProvider.getOptionsFromString(source); |
| 468 var errors = validator.validate(options); | 469 var errors = validator.validate(options); |
| 469 expect(errors.map((AnalysisError e) => e.errorCode), | 470 expect(errors.map((AnalysisError e) => e.errorCode), |
| 470 unorderedEquals(expected)); | 471 unorderedEquals(expected)); |
| 471 } | 472 } |
| 472 } | 473 } |
| 474 |
| 475 class TestRule extends LintRule { |
| 476 TestRule() : super(name: 'fantastic_test_rule'); |
| 477 } |
| OLD | NEW |