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

Unified Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2566003002: When a file is removed from the driver, reschedule full analysis. (Closed)
Patch Set: Created 4 years 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/dart/analysis/file_state.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/dart/analysis/driver_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index d44ef4019f334aa411ec70c02ff0a12b0bcc20db..30086bc9a58358309cc2958fb04d607d94dd6ff0 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -967,24 +967,27 @@ main() {
test_knownFiles() async {
var a = _p('/test/lib/a.dart');
var b = _p('/test/lib/b.dart');
+ var c = _p('/test/lib/c.dart');
provider.newFile(
a,
r'''
import 'b.dart';
''');
+ provider.newFile(b, '');
+ provider.newFile(c, '');
driver.addFile(a);
+ driver.addFile(c);
await _waitForIdle();
- expect(driver.knownFiles, contains(a));
- expect(driver.knownFiles, contains(b));
+ expect(driver.knownFiles, unorderedEquals([a, b, c]));
+ // Remove a.dart and analyze.
+ // Both a.dart and b.dart are not known now.
driver.removeFile(a);
-
- // a.dart was removed, but we don't clean up the file state state yet.
- expect(driver.knownFiles, contains(a));
- expect(driver.knownFiles, contains(b));
+ await _waitForIdle();
+ expect(driver.knownFiles, unorderedEquals([c]));
}
test_knownFiles_beforeAnalysis() async {
@@ -1337,6 +1340,29 @@ var A = B;
expect(allResults, isEmpty);
}
+ test_removeFile_invalidate_importers() async {
+ var a = _p('/test/lib/a.dart');
+ var b = _p('/test/lib/b.dart');
+
+ provider.newFile(a, 'class A {}');
+ provider.newFile(b, "import 'a.dart'; var a = new A();");
+
+ driver.addFile(a);
+ driver.addFile(b);
+ await _waitForIdle();
+
+ // b.dart s clean.
+ expect(allResults.singleWhere((r) => r.path == b).errors, isEmpty);
+ allResults.clear();
+
+ // Remove a.dart, now b.dart should be reanalyzed and has an error.
+ provider.deleteFile(a);
+ driver.removeFile(a);
+ await _waitForIdle();
+ expect(allResults.singleWhere((r) => r.path == b).errors, hasLength(2));
+ allResults.clear();
+ }
+
test_results_priority() async {
String content = 'int f() => 42;';
addTestFile(content, priority: true);
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/file_state.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698