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

Unified Diff: pkg/analysis_server/test/analysis/reanalyze_test.dart

Issue 880643005: Fix "reanalyze sources" when there are unsaved files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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/analysis/reanalyze_test.dart
diff --git a/pkg/analysis_server/test/analysis/reanalyze_test.dart b/pkg/analysis_server/test/analysis/reanalyze_test.dart
index cd3cd0b74d3410c0733355f0506c124705daa0f6..c2c60af0028f0a47106e15ab4efeb2deb4d62c36 100644
--- a/pkg/analysis_server/test/analysis/reanalyze_test.dart
+++ b/pkg/analysis_server/test/analysis/reanalyze_test.dart
@@ -21,6 +21,16 @@ main() {
@reflectiveTest
class ReanalyzeTest extends AbstractAnalysisTest {
+ Map<String, List<AnalysisError>> filesErrors = {};
+
+ @override
+ void processNotification(Notification notification) {
+ if (notification.event == ANALYSIS_ERRORS) {
+ var decoded = new AnalysisErrorsParams.fromNotification(notification);
+ filesErrors[decoded.file] = decoded.errors;
+ }
+ }
+
test_reanalyze() {
createProject();
List<AnalysisContext> contexts = server.folderMap.values.toList();
@@ -34,4 +44,34 @@ class ReanalyzeTest extends AbstractAnalysisTest {
AnalysisContext newContext = contexts[0];
expect(newContext, isNot(same(oldContext)));
}
+
+ test_reanalyze_with_overlay() {
+ createProject();
+ resourceProvider.newFolder(testFolder);
+ resourceProvider.newFile(testFile, 'main() {}');
+ return waitForTasksFinished().then((_) {
+ // Update the content with an overlay that contains a syntax error.
+ server.updateContent('1', {
+ testFile: new AddContentOverlay('main() {')
+ });
+ return waitForTasksFinished();
+ }).then((_) {
+ // Verify that the syntax error was detected.
+ List<AnalysisError> errors = filesErrors[testFile];
+ expect(errors, hasLength(1));
+ // Remove testFile from filesErrors so that we'll notice when the file is
+ // re-analyzed.
+ filesErrors.remove(testFile);
+ // Reanalyze.
+ server.reanalyze();
+ return waitForTasksFinished();
+ }).then((_) {
+ // The file should have been reanalyzed.
+ expect(filesErrors, contains(testFile));
+ // Verify that the syntax error is present (this indicates that the
+ // content introduced by the call to updateContent is still in effect).
+ List<AnalysisError> errors = filesErrors[testFile];
+ expect(errors, hasLength(1));
+ });
+ }
}

Powered by Google App Engine
This is Rietveld 408576698