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

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

Issue 1418533004: Unsupported analysis option validation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Warning type fix. 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
« no previous file with comments | « pkg/analyzer/lib/src/task/options.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cca09f4f5b0c46dec0b5003fc49c137346f473da..8f59117996f49166352c02ef819c668adf134bea 100644
--- a/pkg/analyzer/test/src/task/options_test.dart
+++ b/pkg/analyzer/test/src/task/options_test.dart
@@ -5,6 +5,7 @@
library test.src.task.options_test;
import 'package:analyzer/analyzer.dart';
+import 'package:analyzer/source/analysis_options_provider.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/task/options.dart';
@@ -18,6 +19,7 @@ import '../context/abstract_context.dart';
main() {
initializeTestEnvironment();
runReflectiveTests(GenerateOptionsErrorsTaskTest);
+ runReflectiveTests(OptionsFileValidatorTest);
}
isInstanceOf isGenerateOptionsErrorsTask =
@@ -81,6 +83,21 @@ class GenerateOptionsErrorsTaskTest extends AbstractContextTest {
expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR);
}
+ test_perform_unsupported_analyzer_option() {
+ String code = r'''
+analyzer:
+ not_supported: 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");
+ }
+
test_perform_OK() {
String code = r'''
analyzer:
@@ -92,3 +109,44 @@ analyzer:
expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty);
}
}
+
+@reflectiveTest
+class OptionsFileValidatorTest {
+ final OptionsFileValidator validator = new OptionsFileValidator(null);
+ final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+
+ test_analyzer_supported_exclude() {
+ validate(
+ '''
+analyzer:
+ exclude:
+ - test/_data/p4/lib/lib1.dart
+ ''',
+ []);
+ }
+
+ test_analyzer_supported_strong_mode() {
+ validate(
+ '''
+analyzer:
+ strong-mode: true
+ ''',
+ []);
+ }
+
+ test_analyzer_unsupported_option() {
+ validate(
+ '''
+analyzer:
+ not_supported: true
+ ''',
+ [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION]);
+ }
+
+ void validate(String source, List<AnalysisOptionsErrorCode> expected) {
+ var options = optionsProvider.getOptionsFromString(source);
+ var errors = validator.validate(options);
+ expect(errors.map((AnalysisError e) => e.errorCode),
+ unorderedEquals(expected));
+ }
+}
« no previous file with comments | « 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