Issue 45556. Analyze a requested file, even if it is excluded.
Bug: https://github.com/dart-lang/sdk/issues/45556
Change-Id: I5077759b2929540a3631712a09fce951c3732b51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207400
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index a3b5448..28e3590 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -382,7 +382,7 @@
Iterable<io.File> _collectFiles(String filePath, AnalysisOptions options) {
var files = <io.File>[];
var file = io.File(filePath);
- if (file.existsSync() && !pathFilter.ignored(filePath)) {
+ if (file.existsSync()) {
files.add(file);
} else {
var directory = io.Directory(filePath);
diff --git a/pkg/analyzer_cli/test/driver_test.dart b/pkg/analyzer_cli/test/driver_test.dart
index 419aceb..19d778d 100644
--- a/pkg/analyzer_cli/test/driver_test.dart
+++ b/pkg/analyzer_cli/test/driver_test.dart
@@ -73,7 +73,9 @@
path.join(testDirectory, options),
];
}
- cmd..addAll(sources.map(_adjustFileSpec))..addAll(args);
+ cmd
+ ..addAll(sources.map(_adjustFileSpec))
+ ..addAll(args);
await driver.start(cmd);
}
@@ -390,6 +392,20 @@
ErrorProcessor processorFor(AnalysisError error) =>
processors.firstWhere((p) => p.appliesTo(error));
+ /// If a file is specified explicitly, it should be analyzed, even if
+ /// it is excluded. Excludes work when an including directory is specified.
+ Future<void> test_analysisOptions_excluded_requested() async {
+ await drive(
+ 'data/exclude_test_project/lib/excluded_error.dart',
+ options: 'data/exclude_test_project/$analysisOptionsYaml',
+ );
+ expect(
+ bulletToDash(outSink),
+ contains("error - Undefined class 'ExcludedUndefinedClass'"),
+ );
+ expect(outSink.toString(), contains('1 error found.'));
+ }
+
Future<void> test_analysisOptions_excludes() async {
await drive('data/exclude_test_project',
options: 'data/exclude_test_project/$analysisOptionsYaml');