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

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

Issue 2502233004: report errors in included options files (Closed)
Patch Set: merge Created 4 years, 1 month 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 ce4bf2e89595fc9b355c5b43c24bbae08ddedf2c..be0798ca14bd25e54d5e68e84f635e55a75fddb3 100644
--- a/pkg/analyzer/test/src/task/options_test.dart
+++ b/pkg/analyzer/test/src/task/options_test.dart
@@ -226,6 +226,77 @@ abstract class GenerateOptionsErrorsTaskTest extends AbstractContextTest {
expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR);
}
+ test_perform_include() {
+ newSource('/other_options.yaml', '');
+ String code = r'''
+include: other_options.yaml
+''';
+ AnalysisTarget target = newSource(optionsFilePath, code);
+ computeResult(target, ANALYSIS_OPTIONS_ERRORS);
+ expect(task, isGenerateOptionsErrorsTask);
+ List<AnalysisError> errors =
+ outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
+ expect(errors, hasLength(0));
+ }
+
+ test_perform_include_bad_value() {
+ newSource('/other_options.yaml', '''
+analyzer:
+ errors:
+ unused_local_variable: ftw
+''');
+ String code = r'''
+include: other_options.yaml
+''';
+ AnalysisTarget target = newSource(optionsFilePath, code);
+ computeResult(target, ANALYSIS_OPTIONS_ERRORS);
+ expect(task, isGenerateOptionsErrorsTask);
+ List<AnalysisError> errors =
+ outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
+ expect(errors, hasLength(1));
+ AnalysisError error = errors[0];
+ expect(error.errorCode, AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING);
+ expect(error.source, target.source);
+ expect(error.offset, 10);
+ expect(error.length, 18);
+ expect(error.message, contains('other_options.yaml(47..49)'));
+ }
+
+ test_perform_include_bad_yaml() {
+ newSource('/other_options.yaml', ':');
+ String code = r'''
+include: other_options.yaml
+''';
+ AnalysisTarget target = newSource(optionsFilePath, code);
+ computeResult(target, ANALYSIS_OPTIONS_ERRORS);
+ expect(task, isGenerateOptionsErrorsTask);
+ List<AnalysisError> errors =
+ outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
+ expect(errors, hasLength(1));
+ AnalysisError error = errors[0];
+ expect(error.errorCode, AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR);
+ expect(error.source, target.source);
+ expect(error.offset, 10);
+ expect(error.length, 18);
+ expect(error.message, contains('other_options.yaml(0..0)'));
+ }
+
+ test_perform_include_missing() {
+ String code = r'''
+include: other_options.yaml
+''';
+ AnalysisTarget target = newSource(optionsFilePath, code);
+ computeResult(target, ANALYSIS_OPTIONS_ERRORS);
+ expect(task, isGenerateOptionsErrorsTask);
+ List<AnalysisError> errors =
+ outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
+ expect(errors, hasLength(1));
+ AnalysisError error = errors[0];
+ expect(error.errorCode, AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND);
+ expect(error.offset, 10);
+ expect(error.length, 18);
+ }
+
test_perform_OK() {
String code = r'''
analyzer:
« 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