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

Side by Side Diff: pkg/analysis_server/test/integration/integration_tests.dart

Issue 2808623002: Add 4 integration tests for the analysis domain. (Closed)
Patch Set: dartfmt Created 3 years, 8 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
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.integration.analysis; 5 library test.integration.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Directory sourceDirectory; 108 Directory sourceDirectory;
109 109
110 /** 110 /**
111 * Map from file path to the list of analysis errors which have most recently 111 * Map from file path to the list of analysis errors which have most recently
112 * been received for the file. 112 * been received for the file.
113 */ 113 */
114 HashMap<String, List<AnalysisError>> currentAnalysisErrors = 114 HashMap<String, List<AnalysisError>> currentAnalysisErrors =
115 new HashMap<String, List<AnalysisError>>(); 115 new HashMap<String, List<AnalysisError>>();
116 116
117 /** 117 /**
118 * The last list of analyzed files received.
119 */
120 List<String> lastAnalyzedFiles;
121
122 /**
118 * True if the teardown process should skip sending a "server.shutdown" 123 * True if the teardown process should skip sending a "server.shutdown"
119 * request (e.g. because the server is known to have already shutdown). 124 * request (e.g. because the server is known to have already shutdown).
120 */ 125 */
121 bool skipShutdown = false; 126 bool skipShutdown = false;
122 127
123 /** 128 /**
124 * True if we are currently subscribed to [SERVER_STATUS] updates. 129 * True if we are currently subscribed to [SERVER_STATUS] updates.
125 */ 130 */
126 bool _subscribedToServerStatus = false; 131 bool _subscribedToServerStatus = false;
127 132
128 AbstractAnalysisServerIntegrationTest() { 133 AbstractAnalysisServerIntegrationTest() {
129 initializeInttestMixin(); 134 initializeInttestMixin();
130 } 135 }
131 136
132 /** 137 /**
133 * Return a future which will complete when a 'server.status' notification is 138 * Return a future which will complete when a 'server.status' notification is
134 * received from the server with 'analyzing' set to false. 139 * received from the server with 'analyzing' set to false.
135 * 140 *
136 * The future will only be completed by 'server.status' notifications that are 141 * The future will only be completed by 'server.status' notifications that are
137 * received after this function call. So it is safe to use this getter 142 * received after this function call. So it is safe to use this getter
138 * multiple times in one test; each time it is used it will wait afresh for 143 * multiple times in one test; each time it is used it will wait afresh for
139 * analysis to finish. 144 * analysis to finish.
140 */ 145 */
141 Future get analysisFinished { 146 Future<ServerStatusParams> get analysisFinished {
142 Completer completer = new Completer(); 147 Completer completer = new Completer();
143 StreamSubscription subscription; 148 StreamSubscription subscription;
144 // This will only work if the caller has already subscribed to 149 // This will only work if the caller has already subscribed to
145 // SERVER_STATUS (e.g. using sendServerSetSubscriptions(['STATUS'])) 150 // SERVER_STATUS (e.g. using sendServerSetSubscriptions(['STATUS']))
146 outOfTestExpect(_subscribedToServerStatus, isTrue); 151 outOfTestExpect(_subscribedToServerStatus, isTrue);
147 subscription = onServerStatus.listen((ServerStatusParams params) { 152 subscription = onServerStatus.listen((ServerStatusParams params) {
148 if (params.analysis != null && !params.analysis.isAnalyzing) { 153 if (params.analysis != null && !params.analysis.isAnalyzing) {
149 completer.complete(params); 154 completer.complete(params);
150 subscription.cancel(); 155 subscription.cancel();
151 } 156 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 * [sourceDirectory] is created. 190 * [sourceDirectory] is created.
186 */ 191 */
187 Future setUp() async { 192 Future setUp() async {
188 sourceDirectory = new Directory(Directory.systemTemp 193 sourceDirectory = new Directory(Directory.systemTemp
189 .createTempSync('analysisServer') 194 .createTempSync('analysisServer')
190 .resolveSymbolicLinksSync()); 195 .resolveSymbolicLinksSync());
191 196
192 onAnalysisErrors.listen((AnalysisErrorsParams params) { 197 onAnalysisErrors.listen((AnalysisErrorsParams params) {
193 currentAnalysisErrors[params.file] = params.errors; 198 currentAnalysisErrors[params.file] = params.errors;
194 }); 199 });
200 onAnalysisAnalyzedFiles.listen((AnalysisAnalyzedFilesParams params) {
201 lastAnalyzedFiles = params.directories;
202 });
195 Completer serverConnected = new Completer(); 203 Completer serverConnected = new Completer();
196 onServerConnected.listen((_) { 204 onServerConnected.listen((_) {
197 outOfTestExpect(serverConnected.isCompleted, isFalse); 205 outOfTestExpect(serverConnected.isCompleted, isFalse);
198 serverConnected.complete(); 206 serverConnected.complete();
199 }); 207 });
200 onServerError.listen((ServerErrorParams params) { 208 onServerError.listen((ServerErrorParams params) {
201 // A server error should never happen during an integration test. 209 // A server error should never happen during an integration test.
202 fail('${params.message}\n${params.stackTrace}'); 210 fail('${params.message}\n${params.stackTrace}');
203 }); 211 });
204 await startServer(); 212 await startServer();
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 void populateMismatches(item, List<MismatchDescriber> mismatches); 990 void populateMismatches(item, List<MismatchDescriber> mismatches);
983 991
984 /** 992 /**
985 * Create a [MismatchDescriber] describing a mismatch with a simple string. 993 * Create a [MismatchDescriber] describing a mismatch with a simple string.
986 */ 994 */
987 MismatchDescriber simpleDescription(String description) => 995 MismatchDescriber simpleDescription(String description) =>
988 (Description mismatchDescription) { 996 (Description mismatchDescription) {
989 mismatchDescription.add(description); 997 mismatchDescription.add(description);
990 }; 998 };
991 } 999 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698