| OLD | NEW |
| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (subscribeStatus) { | 198 if (subscribeStatus) { |
| 199 futures.add(sendServerSetSubscriptions([ServerService.STATUS])); | 199 futures.add(sendServerSetSubscriptions([ServerService.STATUS])); |
| 200 } | 200 } |
| 201 futures.add(sendAnalysisSetAnalysisRoots([sourceDirectory.path], [])); | 201 futures.add(sendAnalysisSetAnalysisRoots([sourceDirectory.path], [])); |
| 202 return Future.wait(futures); | 202 return Future.wait(futures); |
| 203 } | 203 } |
| 204 | 204 |
| 205 /** | 205 /** |
| 206 * Start [server]. | 206 * Start [server]. |
| 207 */ | 207 */ |
| 208 Future startServer() => server.start(); | 208 Future startServer({int servicesPort}) => |
| 209 server.start(servicesPort: servicesPort); |
| 209 | 210 |
| 210 /** | 211 /** |
| 211 * After every test, the server is stopped and [sourceDirectory] is deleted. | 212 * After every test, the server is stopped and [sourceDirectory] is deleted. |
| 212 */ | 213 */ |
| 213 Future tearDown() { | 214 Future tearDown() { |
| 214 return shutdownIfNeeded().then((_) { | 215 return shutdownIfNeeded().then((_) { |
| 215 sourceDirectory.deleteSync(recursive: true); | 216 sourceDirectory.deleteSync(recursive: true); |
| 216 }); | 217 }); |
| 217 } | 218 } |
| 218 | 219 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 * Start listening to output from the server, and deliver notifications to | 503 * Start listening to output from the server, and deliver notifications to |
| 503 * [notificationProcessor]. | 504 * [notificationProcessor]. |
| 504 */ | 505 */ |
| 505 void listenToOutput(NotificationProcessor notificationProcessor) { | 506 void listenToOutput(NotificationProcessor notificationProcessor) { |
| 506 _process.stdout | 507 _process.stdout |
| 507 .transform((new Utf8Codec()).decoder) | 508 .transform((new Utf8Codec()).decoder) |
| 508 .transform(new LineSplitter()) | 509 .transform(new LineSplitter()) |
| 509 .listen((String line) { | 510 .listen((String line) { |
| 510 lastCommunicationTime = currentElapseTime; | 511 lastCommunicationTime = currentElapseTime; |
| 511 String trimmedLine = line.trim(); | 512 String trimmedLine = line.trim(); |
| 513 if (trimmedLine.startsWith('Observatory listening on ')) { |
| 514 return; |
| 515 } |
| 512 _recordStdio('RECV: $trimmedLine'); | 516 _recordStdio('RECV: $trimmedLine'); |
| 513 var message; | 517 var message; |
| 514 try { | 518 try { |
| 515 message = JSON.decoder.convert(trimmedLine); | 519 message = JSON.decoder.convert(trimmedLine); |
| 516 } catch (exception) { | 520 } catch (exception) { |
| 517 _badDataFromServer('JSON decode failure: $exception'); | 521 _badDataFromServer('JSON decode failure: $exception'); |
| 518 return; | 522 return; |
| 519 } | 523 } |
| 520 expect(message, isMap); | 524 expect(message, isMap); |
| 521 Map messageAsMap = message; | 525 Map messageAsMap = message; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 /** | 593 /** |
| 590 * Start the server. If [debugServer] is `true`, the server will be started | 594 * Start the server. If [debugServer] is `true`, the server will be started |
| 591 * with "--debug", allowing a debugger to be attached. If [profileServer] is | 595 * with "--debug", allowing a debugger to be attached. If [profileServer] is |
| 592 * `true`, the server will be started with "--observe" and | 596 * `true`, the server will be started with "--observe" and |
| 593 * "--pause-isolates-on-exit", allowing the observatory to be used. | 597 * "--pause-isolates-on-exit", allowing the observatory to be used. |
| 594 */ | 598 */ |
| 595 Future start( | 599 Future start( |
| 596 {bool debugServer: false, | 600 {bool debugServer: false, |
| 597 int diagnosticPort, | 601 int diagnosticPort, |
| 598 bool profileServer: false, | 602 bool profileServer: false, |
| 603 int servicesPort, |
| 599 bool useAnalysisHighlight2: false}) { | 604 bool useAnalysisHighlight2: false}) { |
| 600 if (_process != null) { | 605 if (_process != null) { |
| 601 throw new Exception('Process already started'); | 606 throw new Exception('Process already started'); |
| 602 } | 607 } |
| 603 _time.start(); | 608 _time.start(); |
| 604 String dartBinary = Platform.executable; | 609 String dartBinary = Platform.executable; |
| 605 String rootDir = | 610 String rootDir = |
| 606 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); | 611 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); |
| 607 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); | 612 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); |
| 608 List<String> arguments = []; | 613 List<String> arguments = []; |
| 609 if (debugServer) { | 614 if (debugServer) { |
| 610 arguments.add('--debug'); | 615 arguments.add('--debug'); |
| 611 } | 616 } |
| 612 if (profileServer) { | 617 if (profileServer) { |
| 613 arguments.add('--observe'); | 618 if (servicesPort == null) { |
| 619 arguments.add('--observe'); |
| 620 } else { |
| 621 arguments.add('--observe=$servicesPort'); |
| 622 } |
| 614 arguments.add('--pause-isolates-on-exit'); | 623 arguments.add('--pause-isolates-on-exit'); |
| 624 } else if (servicesPort != null) { |
| 625 arguments.add('--enable-vm-service=$servicesPort'); |
| 615 } | 626 } |
| 616 if (Platform.packageRoot != null) { | 627 if (Platform.packageRoot != null) { |
| 617 arguments.add('--package-root=${Platform.packageRoot}'); | 628 arguments.add('--package-root=${Platform.packageRoot}'); |
| 618 } | 629 } |
| 619 arguments.add('--checked'); | 630 arguments.add('--checked'); |
| 620 arguments.add(serverPath); | 631 arguments.add(serverPath); |
| 621 if (diagnosticPort != null) { | 632 if (diagnosticPort != null) { |
| 622 arguments.add('--port'); | 633 arguments.add('--port'); |
| 623 arguments.add(diagnosticPort.toString()); | 634 arguments.add(diagnosticPort.toString()); |
| 624 } | 635 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 void populateMismatches(item, List<MismatchDescriber> mismatches); | 897 void populateMismatches(item, List<MismatchDescriber> mismatches); |
| 887 | 898 |
| 888 /** | 899 /** |
| 889 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 900 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
| 890 */ | 901 */ |
| 891 MismatchDescriber simpleDescription(String description) => | 902 MismatchDescriber simpleDescription(String description) => |
| 892 (Description mismatchDescription) { | 903 (Description mismatchDescription) { |
| 893 mismatchDescription.add(description); | 904 mismatchDescription.add(description); |
| 894 }; | 905 }; |
| 895 } | 906 } |
| OLD | NEW |