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

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

Issue 2696323004: Tests for analysis.navigation. (Closed)
Patch Set: 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 @override 169 @override
170 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { 170 Future sendServerSetSubscriptions(List<ServerService> subscriptions) {
171 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); 171 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS);
172 return super.sendServerSetSubscriptions(subscriptions); 172 return super.sendServerSetSubscriptions(subscriptions);
173 } 173 }
174 174
175 /** 175 /**
176 * The server is automatically started before every test, and a temporary 176 * The server is automatically started before every test, and a temporary
177 * [sourceDirectory] is created. 177 * [sourceDirectory] is created.
178 */ 178 */
179 Future setUp() { 179 Future setUp() async {
180 sourceDirectory = new Directory(Directory.systemTemp 180 sourceDirectory = new Directory(Directory.systemTemp
181 .createTempSync('analysisServer') 181 .createTempSync('analysisServer')
182 .resolveSymbolicLinksSync()); 182 .resolveSymbolicLinksSync());
183 183
184 onAnalysisErrors.listen((AnalysisErrorsParams params) { 184 onAnalysisErrors.listen((AnalysisErrorsParams params) {
185 currentAnalysisErrors[params.file] = params.errors; 185 currentAnalysisErrors[params.file] = params.errors;
186 }); 186 });
187 Completer serverConnected = new Completer(); 187 Completer serverConnected = new Completer();
188 onServerConnected.listen((_) { 188 onServerConnected.listen((_) {
189 outOfTestExpect(serverConnected.isCompleted, isFalse); 189 outOfTestExpect(serverConnected.isCompleted, isFalse);
190 serverConnected.complete(); 190 serverConnected.complete();
191 }); 191 });
192 onServerError.listen((ServerErrorParams params) { 192 onServerError.listen((ServerErrorParams params) {
193 // A server error should never happen during an integration test. 193 // A server error should never happen during an integration test.
194 fail('${params.message}\n${params.stackTrace}'); 194 fail('${params.message}\n${params.stackTrace}');
195 }); 195 });
196 return startServer().then((_) { 196 await startServer();
197 server.listenToOutput(dispatchNotification); 197 server.listenToOutput(dispatchNotification);
198 server.exitCode.then((_) { 198 server.exitCode.then((_) {
199 skipShutdown = true; 199 skipShutdown = true;
200 });
201 return serverConnected.future;
202 }); 200 });
201 return serverConnected.future;
203 } 202 }
204 203
205 /** 204 /**
206 * If [skipShutdown] is not set, shut down the server. 205 * If [skipShutdown] is not set, shut down the server.
207 */ 206 */
208 Future shutdownIfNeeded() { 207 Future shutdownIfNeeded() {
209 if (skipShutdown) { 208 if (skipShutdown) {
210 return new Future.value(); 209 return new Future.value();
211 } 210 }
212 // Give the server a short time to comply with the shutdown request; if it 211 // 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 } 643 }
645 Completer completer = new Completer(); 644 Completer completer = new Completer();
646 _pendingCommands[id] = completer; 645 _pendingCommands[id] = completer;
647 String line = JSON.encode(command); 646 String line = JSON.encode(command);
648 _recordStdio('SEND: $line'); 647 _recordStdio('SEND: $line');
649 _process.stdin.add(UTF8.encoder.convert("$line\n")); 648 _process.stdin.add(UTF8.encoder.convert("$line\n"));
650 return completer.future; 649 return completer.future;
651 } 650 }
652 651
653 /** 652 /**
654 * Start the server. If [debugServer] is `true`, the server will be started 653 * Start the server. If [profileServer] is `true`, the server will be started
655 * with "--debug", allowing a debugger to be attached. If [profileServer] is 654 * with "--observe" and "--pause-isolates-on-exit", allowing the observatory
656 * `true`, the server will be started with "--observe" and 655 * to be used.
657 * "--pause-isolates-on-exit", allowing the observatory to be used.
658 */ 656 */
659 Future start( 657 Future start(
660 {bool checked: true, 658 {bool checked: true,
661 bool debugServer: false,
662 int diagnosticPort, 659 int diagnosticPort,
663 bool enableNewAnalysisDriver: false, 660 bool enableNewAnalysisDriver: false,
664 bool noErrorNotification: false, 661 bool noErrorNotification: false,
665 bool profileServer: false, 662 bool profileServer: false,
666 String sdkPath, 663 String sdkPath,
667 int servicesPort, 664 int servicesPort,
668 bool useAnalysisHighlight2: false}) { 665 bool useAnalysisHighlight2: false}) {
669 if (_process != null) { 666 if (_process != null) {
670 throw new Exception('Process already started'); 667 throw new Exception('Process already started');
671 } 668 }
672 _time.start(); 669 _time.start();
673 String dartBinary = Platform.executable; 670 String dartBinary = Platform.executable;
674 String rootDir = 671 String rootDir =
675 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); 672 findRoot(Platform.script.toFilePath(windows: Platform.isWindows));
676 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); 673 String serverPath = normalize(join(rootDir, 'bin', 'server.dart'));
677 List<String> arguments = []; 674 List<String> arguments = [];
678 // 675 //
679 // Add VM arguments. 676 // Add VM arguments.
680 // 677 //
681 if (debugServer) {
682 arguments.add('--debug');
683 }
684 if (profileServer) { 678 if (profileServer) {
685 if (servicesPort == null) { 679 if (servicesPort == null) {
686 arguments.add('--observe'); 680 arguments.add('--observe');
687 } else { 681 } else {
688 arguments.add('--observe=$servicesPort'); 682 arguments.add('--observe=$servicesPort');
689 } 683 }
690 arguments.add('--pause-isolates-on-exit'); 684 arguments.add('--pause-isolates-on-exit');
691 } else if (servicesPort != null) { 685 } else if (servicesPort != null) {
692 arguments.add('--enable-vm-service=$servicesPort'); 686 arguments.add('--enable-vm-service=$servicesPort');
693 } 687 }
(...skipping 24 matching lines...) Expand all
718 arguments.add('--useAnalysisHighlight2'); 712 arguments.add('--useAnalysisHighlight2');
719 } 713 }
720 if (!enableNewAnalysisDriver) { 714 if (!enableNewAnalysisDriver) {
721 arguments.add('--disable-new-analysis-driver'); 715 arguments.add('--disable-new-analysis-driver');
722 } 716 }
723 if (noErrorNotification) { 717 if (noErrorNotification) {
724 arguments.add('--no-error-notification'); 718 arguments.add('--no-error-notification');
725 } 719 }
726 // print('Launching $serverPath'); 720 // print('Launching $serverPath');
727 // print('$dartBinary ${arguments.join(' ')}'); 721 // print('$dartBinary ${arguments.join(' ')}');
722 // TODO(devoncarew): We could experiment with instead launching the analysis
723 // server in a separate isolate. This would make it easier to debug the
724 // integration tests, and would like speed the tests up as well.
Brian Wilkerson 2017/02/16 14:57:43 But then they wouldn't be true integration tests.
728 return Process.start(dartBinary, arguments).then((Process process) { 725 return Process.start(dartBinary, arguments).then((Process process) {
729 _process = process; 726 _process = process;
730 process.exitCode.then((int code) { 727 process.exitCode.then((int code) {
731 if (code != 0) { 728 if (code != 0) {
732 _badDataFromServer('server terminated with exit code $code'); 729 _badDataFromServer('server terminated with exit code $code');
733 } 730 }
734 }); 731 });
735 }); 732 });
736 } 733 }
737 734
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void populateMismatches(item, List<MismatchDescriber> mismatches); 981 void populateMismatches(item, List<MismatchDescriber> mismatches);
985 982
986 /** 983 /**
987 * Create a [MismatchDescriber] describing a mismatch with a simple string. 984 * Create a [MismatchDescriber] describing a mismatch with a simple string.
988 */ 985 */
989 MismatchDescriber simpleDescription(String description) => 986 MismatchDescriber simpleDescription(String description) =>
990 (Description mismatchDescription) { 987 (Description mismatchDescription) {
991 mismatchDescription.add(description); 988 mismatchDescription.add(description);
992 }; 989 };
993 } 990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698