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

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

Issue 2696323004: Tests for analysis.navigation. (Closed)
Patch Set: review updates Created 3 years, 10 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * True if the teardown process should skip sending a "server.shutdown" 118 * True if the teardown process should skip sending a "server.shutdown"
119 * request (e.g. because the server is known to have already shutdown). 119 * request (e.g. because the server is known to have already shutdown).
120 */ 120 */
121 bool skipShutdown = false; 121 bool skipShutdown = false;
122 122
123 /** 123 /**
124 * True if we are currently subscribed to [SERVER_STATUS] updates. 124 * True if we are currently subscribed to [SERVER_STATUS] updates.
125 */ 125 */
126 bool _subscribedToServerStatus = false; 126 bool _subscribedToServerStatus = false;
127 127
128 List<AnalysisError> getErrors(String pathname) => currentAnalysisErrors[pathna me];
129
128 AbstractAnalysisServerIntegrationTest() { 130 AbstractAnalysisServerIntegrationTest() {
129 initializeInttestMixin(); 131 initializeInttestMixin();
130 } 132 }
131 133
132 /** 134 /**
133 * Return a future which will complete when a 'server.status' notification is 135 * Return a future which will complete when a 'server.status' notification is
134 * received from the server with 'analyzing' set to false. 136 * received from the server with 'analyzing' set to false.
135 * 137 *
136 * The future will only be completed by 'server.status' notifications that are 138 * 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 139 * received after this function call. So it is safe to use this getter
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 @override 171 @override
170 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { 172 Future sendServerSetSubscriptions(List<ServerService> subscriptions) {
171 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); 173 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS);
172 return super.sendServerSetSubscriptions(subscriptions); 174 return super.sendServerSetSubscriptions(subscriptions);
173 } 175 }
174 176
175 /** 177 /**
176 * The server is automatically started before every test, and a temporary 178 * The server is automatically started before every test, and a temporary
177 * [sourceDirectory] is created. 179 * [sourceDirectory] is created.
178 */ 180 */
179 Future setUp() { 181 Future setUp() async {
180 sourceDirectory = new Directory(Directory.systemTemp 182 sourceDirectory = new Directory(Directory.systemTemp
181 .createTempSync('analysisServer') 183 .createTempSync('analysisServer')
182 .resolveSymbolicLinksSync()); 184 .resolveSymbolicLinksSync());
183 185
184 onAnalysisErrors.listen((AnalysisErrorsParams params) { 186 onAnalysisErrors.listen((AnalysisErrorsParams params) {
185 currentAnalysisErrors[params.file] = params.errors; 187 currentAnalysisErrors[params.file] = params.errors;
186 }); 188 });
187 Completer serverConnected = new Completer(); 189 Completer serverConnected = new Completer();
188 onServerConnected.listen((_) { 190 onServerConnected.listen((_) {
189 outOfTestExpect(serverConnected.isCompleted, isFalse); 191 outOfTestExpect(serverConnected.isCompleted, isFalse);
190 serverConnected.complete(); 192 serverConnected.complete();
191 }); 193 });
192 onServerError.listen((ServerErrorParams params) { 194 onServerError.listen((ServerErrorParams params) {
193 // A server error should never happen during an integration test. 195 // A server error should never happen during an integration test.
194 fail('${params.message}\n${params.stackTrace}'); 196 fail('${params.message}\n${params.stackTrace}');
195 }); 197 });
196 return startServer().then((_) { 198 await startServer();
197 server.listenToOutput(dispatchNotification); 199 server.listenToOutput(dispatchNotification);
198 server.exitCode.then((_) { 200 server.exitCode.then((_) {
199 skipShutdown = true; 201 skipShutdown = true;
200 });
201 return serverConnected.future;
202 }); 202 });
203 return serverConnected.future;
203 } 204 }
204 205
205 /** 206 /**
206 * If [skipShutdown] is not set, shut down the server. 207 * If [skipShutdown] is not set, shut down the server.
207 */ 208 */
208 Future shutdownIfNeeded() { 209 Future shutdownIfNeeded() {
209 if (skipShutdown) { 210 if (skipShutdown) {
210 return new Future.value(); 211 return new Future.value();
211 } 212 }
212 // Give the server a short time to comply with the shutdown request; if it 213 // Give the server a short time to comply with the shutdown request; if it
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 645 }
645 Completer completer = new Completer(); 646 Completer completer = new Completer();
646 _pendingCommands[id] = completer; 647 _pendingCommands[id] = completer;
647 String line = JSON.encode(command); 648 String line = JSON.encode(command);
648 _recordStdio('SEND: $line'); 649 _recordStdio('SEND: $line');
649 _process.stdin.add(UTF8.encoder.convert("$line\n")); 650 _process.stdin.add(UTF8.encoder.convert("$line\n"));
650 return completer.future; 651 return completer.future;
651 } 652 }
652 653
653 /** 654 /**
654 * Start the server. If [debugServer] is `true`, the server will be started 655 * Start the server. If [profileServer] is `true`, the server will be started
655 * with "--debug", allowing a debugger to be attached. If [profileServer] is 656 * with "--observe" and "--pause-isolates-on-exit", allowing the observatory
656 * `true`, the server will be started with "--observe" and 657 * to be used.
657 * "--pause-isolates-on-exit", allowing the observatory to be used.
658 */ 658 */
659 Future start( 659 Future start(
660 {bool checked: true, 660 {bool checked: true,
661 bool debugServer: false,
662 int diagnosticPort, 661 int diagnosticPort,
663 bool enableNewAnalysisDriver: false, 662 bool enableNewAnalysisDriver: false,
664 bool noErrorNotification: false, 663 bool noErrorNotification: false,
665 bool profileServer: false, 664 bool profileServer: false,
666 String sdkPath, 665 String sdkPath,
667 int servicesPort, 666 int servicesPort,
668 bool useAnalysisHighlight2: false}) { 667 bool useAnalysisHighlight2: false}) {
669 if (_process != null) { 668 if (_process != null) {
670 throw new Exception('Process already started'); 669 throw new Exception('Process already started');
671 } 670 }
672 _time.start(); 671 _time.start();
673 String dartBinary = Platform.executable; 672 String dartBinary = Platform.executable;
674 String rootDir = 673 String rootDir =
675 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); 674 findRoot(Platform.script.toFilePath(windows: Platform.isWindows));
676 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); 675 String serverPath = normalize(join(rootDir, 'bin', 'server.dart'));
677 List<String> arguments = []; 676 List<String> arguments = [];
678 // 677 //
679 // Add VM arguments. 678 // Add VM arguments.
680 // 679 //
681 if (debugServer) {
682 arguments.add('--debug');
683 }
684 if (profileServer) { 680 if (profileServer) {
685 if (servicesPort == null) { 681 if (servicesPort == null) {
686 arguments.add('--observe'); 682 arguments.add('--observe');
687 } else { 683 } else {
688 arguments.add('--observe=$servicesPort'); 684 arguments.add('--observe=$servicesPort');
689 } 685 }
690 arguments.add('--pause-isolates-on-exit'); 686 arguments.add('--pause-isolates-on-exit');
691 } else if (servicesPort != null) { 687 } else if (servicesPort != null) {
692 arguments.add('--enable-vm-service=$servicesPort'); 688 arguments.add('--enable-vm-service=$servicesPort');
693 } 689 }
(...skipping 24 matching lines...) Expand all
718 arguments.add('--useAnalysisHighlight2'); 714 arguments.add('--useAnalysisHighlight2');
719 } 715 }
720 if (!enableNewAnalysisDriver) { 716 if (!enableNewAnalysisDriver) {
721 arguments.add('--disable-new-analysis-driver'); 717 arguments.add('--disable-new-analysis-driver');
722 } 718 }
723 if (noErrorNotification) { 719 if (noErrorNotification) {
724 arguments.add('--no-error-notification'); 720 arguments.add('--no-error-notification');
725 } 721 }
726 // print('Launching $serverPath'); 722 // print('Launching $serverPath');
727 // print('$dartBinary ${arguments.join(' ')}'); 723 // print('$dartBinary ${arguments.join(' ')}');
724 // TODO(devoncarew): We could experiment with instead launching the analysis
725 // server in a separate isolate. This would make it easier to debug the
726 // integration tests, and would like speed the tests up as well.
728 return Process.start(dartBinary, arguments).then((Process process) { 727 return Process.start(dartBinary, arguments).then((Process process) {
729 _process = process; 728 _process = process;
730 process.exitCode.then((int code) { 729 process.exitCode.then((int code) {
731 if (code != 0) { 730 if (code != 0) {
732 _badDataFromServer('server terminated with exit code $code'); 731 _badDataFromServer('server terminated with exit code $code');
733 } 732 }
734 }); 733 });
735 }); 734 });
736 } 735 }
737 736
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void populateMismatches(item, List<MismatchDescriber> mismatches); 983 void populateMismatches(item, List<MismatchDescriber> mismatches);
985 984
986 /** 985 /**
987 * Create a [MismatchDescriber] describing a mismatch with a simple string. 986 * Create a [MismatchDescriber] describing a mismatch with a simple string.
988 */ 987 */
989 MismatchDescriber simpleDescription(String description) => 988 MismatchDescriber simpleDescription(String description) =>
990 (Description mismatchDescription) { 989 (Description mismatchDescription) {
991 mismatchDescription.add(description); 990 mismatchDescription.add(description);
992 }; 991 };
993 } 992 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/coverage.md ('k') | pkg/analysis_server/test/stress/utilities/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698