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

Unified Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 1420363005: Error Suppression FTW. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Test 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
Index: pkg/analysis_server/test/context_manager_test.dart
diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
index 26f85a2b7804dbce1bd0ce51ffa96e791f9e35fd..42ff840de8d18f67ce4853396fc9326295a33773 100644
--- a/pkg/analysis_server/test/context_manager_test.dart
+++ b/pkg/analysis_server/test/context_manager_test.dart
@@ -11,6 +11,7 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:package_config/packages.dart';
@@ -136,6 +137,69 @@ class AbstractContextManagerTest {
expect(contexts, contains(subProjContextInfo.context));
}
+ test_error_filter_analysis_option() async {
+ // Create files.
+ newFile(
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
+ r'''
+analyzer:
+ errors:
+ unused_local_variable: ignore
+''');
+ // Setup context.
+ manager.setRoots(<String>[projPath], <String>[], <String, String>{});
+
+ // Verify filter setup.
+ List<ErrorFilter> filters =
+ callbacks.currentContext.getConfigurationData(CONFIGURED_ERROR_FILTERS);
+ expect(filters, isNotNull);
+ expect(filters, hasLength(1));
+ expect(
+ filters.first(new AnalysisError(
+ new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
+ ['x']
+ ])),
+ isTrue);
+ }
+
+ test_error_filter_analysis_option_synonyms() async {
+ // Create files.
+ newFile(
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
+ r'''
+analyzer:
+ errors:
+ unused_local_variable: ignore
+ ambiguous_import: false
+''');
+ // Setup context.
+ manager.setRoots(<String>[projPath], <String>[], <String, String>{});
+
+ // Verify filter setup.
+ List<ErrorFilter> filters =
+ callbacks.currentContext.getConfigurationData(CONFIGURED_ERROR_FILTERS);
+ expect(filters, isNotNull);
+ expect(filters, hasLength(2));
+ }
+
+ test_error_filter_analysis_option_unpsecified() async {
+ // Create files.
+ newFile(
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
+ r'''
+analyzer:
+# errors:
+# unused_local_variable: ignore
+''');
+ // Setup context.
+ manager.setRoots(<String>[projPath], <String>[], <String, String>{});
+
+ // Verify filter setup.
+ List<ErrorFilter> filters =
+ callbacks.currentContext.getConfigurationData(CONFIGURED_ERROR_FILTERS);
+ expect(filters, isEmpty);
+ }
+
test_ignoreFilesInPackagesFolder() {
// create a context with a pubspec.yaml file
String pubspecPath = posix.join(projPath, 'pubspec.yaml');
@@ -233,7 +297,7 @@ class AbstractContextManagerTest {
newFile([sdkExtSrcPath, 'part.dart']);
// Setup analysis options file with ignore list.
newFile(
- [projPath, '.analysis_options'],
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
r'''
analyzer:
exclude:
@@ -270,7 +334,7 @@ name: other_lib
// Setup analysis options file with ignore list that ignores the 'other_lib'
// directory by name.
newFile(
- [projPath, '.analysis_options'],
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
r'''
analyzer:
exclude:
@@ -306,7 +370,7 @@ analyzer:
// Setup analysis options file with ignore list that ignores 'other_lib'
// and all descendants.
newFile(
- [projPath, '.analysis_options'],
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
r'''
analyzer:
exclude:
@@ -342,7 +406,7 @@ name: other_lib
// Setup analysis options file with ignore list that ignores 'other_lib'
// and all immediate children.
newFile(
- [projPath, '.analysis_options'],
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
r'''
analyzer:
exclude:
@@ -1133,7 +1197,7 @@ test_pack:lib/
test_strong_mode_analysis_option() async {
// Create files.
newFile(
- [projPath, '.analysis_options'],
+ [projPath, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
r'''
analyzer:
strong-mode: true
« no previous file with comments | « pkg/analysis_server/test/analysis/notification_analysis_options_test.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698