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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 * Start the server. If [debugServer] is `true`, the server will be started | 591 * Start the server. If [debugServer] is `true`, the server will be started |
592 * with "--debug", allowing a debugger to be attached. If [profileServer] is | 592 * with "--debug", allowing a debugger to be attached. If [profileServer] is |
593 * `true`, the server will be started with "--observe" and | 593 * `true`, the server will be started with "--observe" and |
594 * "--pause-isolates-on-exit", allowing the observatory to be used. | 594 * "--pause-isolates-on-exit", allowing the observatory to be used. |
595 */ | 595 */ |
596 Future start( | 596 Future start( |
597 {bool debugServer: false, | 597 {bool debugServer: false, |
598 int diagnosticPort, | 598 int diagnosticPort, |
599 bool profileServer: false, | 599 bool profileServer: false, |
600 bool newTaskModel: false, | 600 bool newTaskModel: false, |
601 bool useAnalysisHighlight2: false}) { | 601 bool useAnalysisHighlight2: false}) async { |
602 if (_process != null) { | 602 if (_process != null) { |
603 throw new Exception('Process already started'); | 603 throw new Exception('Process already started'); |
604 } | 604 } |
605 _time.start(); | 605 _time.start(); |
606 String dartBinary = Platform.executable; | 606 String dartBinary = Platform.executable; |
607 String rootDir = | 607 String rootDir = |
608 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); | 608 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); |
609 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); | 609 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); |
610 List<String> arguments = []; | 610 List<String> arguments = []; |
611 if (debugServer) { | 611 if (debugServer) { |
612 arguments.add('--debug'); | 612 arguments.add('--debug'); |
613 } | 613 } |
614 if (profileServer) { | 614 if (profileServer) { |
615 arguments.add('--observe'); | 615 arguments.add('--observe'); |
616 arguments.add('--pause-isolates-on-exit'); | 616 arguments.add('--pause-isolates-on-exit'); |
617 } | 617 } |
618 if (Platform.packageRoot.isNotEmpty) { | 618 Uri packageRoot = await Platform.packageRoot; |
619 arguments.add('--package-root=${Platform.packageRoot}'); | 619 if (packageRoot != null) { |
620 arguments.add('--package-root=${packageRoot.toFilePath()}'); | |
620 } | 621 } |
Lasse Reichstein Nielsen
2015/09/22 09:48:25
Add a TODO to support --packages as well.
| |
621 arguments.add('--checked'); | 622 arguments.add('--checked'); |
622 arguments.add(serverPath); | 623 arguments.add(serverPath); |
623 if (diagnosticPort != null) { | 624 if (diagnosticPort != null) { |
624 arguments.add('--port'); | 625 arguments.add('--port'); |
625 arguments.add(diagnosticPort.toString()); | 626 arguments.add(diagnosticPort.toString()); |
626 } | 627 } |
627 if (useAnalysisHighlight2) { | 628 if (useAnalysisHighlight2) { |
628 arguments.add('--useAnalysisHighlight2'); | 629 arguments.add('--useAnalysisHighlight2'); |
629 } | 630 } |
630 if (newTaskModel) { | 631 if (newTaskModel) { |
631 arguments.add('--${analysisServer.Driver.ENABLE_NEW_TASK_MODEL}'); | 632 arguments.add('--${analysisServer.Driver.ENABLE_NEW_TASK_MODEL}'); |
632 } | 633 } |
633 return Process.start(dartBinary, arguments).then((Process process) { | 634 _process = await Process.start(dartBinary, arguments); |
634 _process = process; | 635 _process.exitCode.then((int code) { |
Lasse Reichstein Nielsen
2015/09/22 09:48:25
Tricky. They should consider documenting that this
| |
635 process.exitCode.then((int code) { | 636 _recordStdio('TERMINATED WITH EXIT CODE $code'); |
636 _recordStdio('TERMINATED WITH EXIT CODE $code'); | 637 if (code != 0) { |
637 if (code != 0) { | 638 _badDataFromServer(); |
638 _badDataFromServer(); | 639 } |
639 } | |
640 }); | |
641 }); | 640 }); |
641 // Complete this function with no value, but signalling that the server | |
642 // process has started. | |
643 return null; | |
642 } | 644 } |
643 | 645 |
644 /** | 646 /** |
645 * Deal with bad data received from the server. | 647 * Deal with bad data received from the server. |
646 */ | 648 */ |
647 void _badDataFromServer() { | 649 void _badDataFromServer() { |
648 if (_receivedBadDataFromServer) { | 650 if (_receivedBadDataFromServer) { |
649 // We're already dealing with it. | 651 // We're already dealing with it. |
650 return; | 652 return; |
651 } | 653 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 void populateMismatches(item, List<MismatchDescriber> mismatches); | 888 void populateMismatches(item, List<MismatchDescriber> mismatches); |
887 | 889 |
888 /** | 890 /** |
889 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 891 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
890 */ | 892 */ |
891 MismatchDescriber simpleDescription(String description) => | 893 MismatchDescriber simpleDescription(String description) => |
892 (Description mismatchDescription) { | 894 (Description mismatchDescription) { |
893 mismatchDescription.add(description); | 895 mismatchDescription.add(description); |
894 }; | 896 }; |
895 } | 897 } |
OLD | NEW |