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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.analysis.reanalyze; 5 library test.analysis.reanalyze;
6 6
7 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/protocol.dart'; 8 import 'package:analysis_server/src/protocol.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import '../analysis_abstract.dart'; 12 import '../analysis_abstract.dart';
13 import '../reflective_tests.dart'; 13 import '../reflective_tests.dart';
14 14
15 15
16 main() { 16 main() {
17 groupSep = ' | '; 17 groupSep = ' | ';
18 runReflectiveTests(ReanalyzeTest); 18 runReflectiveTests(ReanalyzeTest);
19 } 19 }
20 20
21 21
22 @reflectiveTest 22 @reflectiveTest
23 class ReanalyzeTest extends AbstractAnalysisTest { 23 class ReanalyzeTest extends AbstractAnalysisTest {
24 Map<String, List<AnalysisError>> filesErrors = {};
25
26 @override
27 void processNotification(Notification notification) {
28 if (notification.event == ANALYSIS_ERRORS) {
29 var decoded = new AnalysisErrorsParams.fromNotification(notification);
30 filesErrors[decoded.file] = decoded.errors;
31 }
32 }
33
24 test_reanalyze() { 34 test_reanalyze() {
25 createProject(); 35 createProject();
26 List<AnalysisContext> contexts = server.folderMap.values.toList(); 36 List<AnalysisContext> contexts = server.folderMap.values.toList();
27 expect(contexts, hasLength(1)); 37 expect(contexts, hasLength(1));
28 AnalysisContext oldContext = contexts[0]; 38 AnalysisContext oldContext = contexts[0];
29 // Reanalyze should cause a brand new context to be built. 39 // Reanalyze should cause a brand new context to be built.
30 Request request = new Request("0", ANALYSIS_REANALYZE); 40 Request request = new Request("0", ANALYSIS_REANALYZE);
31 handleSuccessfulRequest(request); 41 handleSuccessfulRequest(request);
32 contexts = server.folderMap.values.toList(); 42 contexts = server.folderMap.values.toList();
33 expect(contexts, hasLength(1)); 43 expect(contexts, hasLength(1));
34 AnalysisContext newContext = contexts[0]; 44 AnalysisContext newContext = contexts[0];
35 expect(newContext, isNot(same(oldContext))); 45 expect(newContext, isNot(same(oldContext)));
36 } 46 }
47
48 test_reanalyze_with_overlay() {
49 createProject();
50 resourceProvider.newFolder(testFolder);
51 resourceProvider.newFile(testFile, 'main() {}');
52 return waitForTasksFinished().then((_) {
53 // Update the content with an overlay that contains a syntax error.
54 server.updateContent('1', {
55 testFile: new AddContentOverlay('main() {')
56 });
57 return waitForTasksFinished();
58 }).then((_) {
59 // Verify that the syntax error was detected.
60 List<AnalysisError> errors = filesErrors[testFile];
61 expect(errors, hasLength(1));
62 // Remove testFile from filesErrors so that we'll notice when the file is
63 // re-analyzed.
64 filesErrors.remove(testFile);
65 // Reanalyze.
66 server.reanalyze();
67 return waitForTasksFinished();
68 }).then((_) {
69 // The file should have been reanalyzed.
70 expect(filesErrors, contains(testFile));
71 // Verify that the syntax error is present (this indicates that the
72 // content introduced by the call to updateContent is still in effect).
73 List<AnalysisError> errors = filesErrors[testFile];
74 expect(errors, hasLength(1));
75 });
76 }
37 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698