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

Unified Diff: pkg/analyzer/test/src/task/options_test.dart

Issue 1419673006: More options file validation (and API iteration). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/task/options_test.dart
diff --git a/pkg/analyzer/test/src/task/options_test.dart b/pkg/analyzer/test/src/task/options_test.dart
index 8f59117996f49166352c02ef819c668adf134bea..e7b5b571df07bdd501f8fe354f5a04fb222cbdd2 100644
--- a/pkg/analyzer/test/src/task/options_test.dart
+++ b/pkg/analyzer/test/src/task/options_test.dart
@@ -12,6 +12,7 @@ import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/task/model.dart';
import 'package:unittest/unittest.dart';
+import '../../generated/test_support.dart';
import '../../reflective_tests.dart';
import '../../utils.dart';
import '../context/abstract_context.dart';
@@ -83,36 +84,37 @@ class GenerateOptionsErrorsTaskTest extends AbstractContextTest {
expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR);
}
- test_perform_unsupported_analyzer_option() {
+ test_perform_OK() {
String code = r'''
analyzer:
- not_supported: true
+ strong-mode: true
''';
AnalysisTarget target = newSource(optionsFilePath, code);
computeResult(target, ANALYSIS_OPTIONS_ERRORS);
expect(task, isGenerateOptionsErrorsTask);
- List<AnalysisError> errors = outputs[ANALYSIS_OPTIONS_ERRORS];
- expect(errors, hasLength(1));
- expect(errors[0].errorCode, AnalysisOptionsWarningCode.UNSUPPORTED_OPTION);
- expect(errors[0].message,
- "The option 'not_supported' is not supported by analyzer");
+ expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty);
}
- test_perform_OK() {
+ test_perform_unsupported_analyzer_option() {
String code = r'''
analyzer:
- strong-mode: true
+ not_supported: true
''';
AnalysisTarget target = newSource(optionsFilePath, code);
computeResult(target, ANALYSIS_OPTIONS_ERRORS);
expect(task, isGenerateOptionsErrorsTask);
- expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty);
+ List<AnalysisError> errors = outputs[ANALYSIS_OPTIONS_ERRORS];
+ expect(errors, hasLength(1));
+ expect(errors[0].errorCode, AnalysisOptionsWarningCode.UNSUPPORTED_OPTION);
+ expect(errors[0].message,
+ "The option 'not_supported' is not supported by analyzer");
}
}
@reflectiveTest
class OptionsFileValidatorTest {
- final OptionsFileValidator validator = new OptionsFileValidator(null);
+ final OptionsFileValidator validator =
+ new OptionsFileValidator(new TestSource());
final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
test_analyzer_supported_exclude() {
@@ -143,6 +145,25 @@ analyzer:
[AnalysisOptionsWarningCode.UNSUPPORTED_OPTION]);
}
+ test_linter_supported_rules() {
+ validate(
+ '''
+linter:
+ rules:
+ - camel_case_types
+ ''',
+ []);
+ }
+
+ test_linter_unssupported_option() {
+ validate(
+ '''
+linter:
+ unsupported: true
+ ''',
+ [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION]);
+ }
+
void validate(String source, List<AnalysisOptionsErrorCode> expected) {
var options = optionsProvider.getOptionsFromString(source);
var errors = validator.validate(options);
« pkg/analyzer/lib/src/task/options.dart ('K') | « pkg/analyzer/lib/src/task/options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698