| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 if (notificationStream == null) { | 561 if (notificationStream == null) { |
| 562 StreamController notificationController = new StreamController(); | 562 StreamController notificationController = new StreamController(); |
| 563 _notificationControllers[event] = notificationController; | 563 _notificationControllers[event] = notificationController; |
| 564 notificationStream = notificationController.stream.asBroadcastStream(); | 564 notificationStream = notificationController.stream.asBroadcastStream(); |
| 565 _notificationStreams[event] = notificationStream; | 565 _notificationStreams[event] = notificationStream; |
| 566 } | 566 } |
| 567 return notificationStream; | 567 return notificationStream; |
| 568 } | 568 } |
| 569 | 569 |
| 570 /** | 570 /** |
| 571 * Find the root directory of the analysis_server package by proceeding |
| 572 * upward to the 'test' dir, and then going up one more directory. |
| 573 */ |
| 574 String findRoot(String pathname) { |
| 575 while (basename(pathname) != 'test') { |
| 576 String parent = dirname(pathname); |
| 577 if (parent.length >= pathname.length) { |
| 578 throw new Exception("Can't find root directory"); |
| 579 } |
| 580 pathname = parent; |
| 581 } |
| 582 return dirname(pathname); |
| 583 } |
| 584 |
| 585 /** |
| 571 * Start the server. If [debugServer] is true, the server will be started | 586 * Start the server. If [debugServer] is true, the server will be started |
| 572 * with "--debug", allowing a debugger to be attached. | 587 * with "--debug", allowing a debugger to be attached. |
| 573 */ | 588 */ |
| 574 Future start({bool debugServer: false}) { | 589 Future start({bool debugServer: false}) { |
| 575 if (_process != null) { | 590 if (_process != null) { |
| 576 throw new Exception('Process already started'); | 591 throw new Exception('Process already started'); |
| 577 } | 592 } |
| 578 _time.start(); | 593 _time.start(); |
| 579 // TODO(paulberry): move the logic for finding the script, the dart | 594 // TODO(paulberry): move the logic for finding the script, the dart |
| 580 // executable, and the package root into a shell script. | 595 // executable, and the package root into a shell script. |
| 581 String dartBinary = Platform.executable; | 596 String dartBinary = Platform.executable; |
| 582 String scriptDir = dirname(Platform.script.toFilePath(windows: | 597 String rootDir = findRoot(Platform.script.toFilePath(windows: |
| 583 Platform.isWindows)); | 598 Platform.isWindows)); |
| 584 String serverPath = normalize(join(scriptDir, '..', '..', 'bin', | 599 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); |
| 585 'server.dart')); | |
| 586 List<String> arguments = []; | 600 List<String> arguments = []; |
| 587 if (debugServer) { | 601 if (debugServer) { |
| 588 arguments.add('--debug'); | 602 arguments.add('--debug'); |
| 589 } | 603 } |
| 590 if (Platform.packageRoot.isNotEmpty) { | 604 if (Platform.packageRoot.isNotEmpty) { |
| 591 arguments.add('--package-root=${Platform.packageRoot}'); | 605 arguments.add('--package-root=${Platform.packageRoot}'); |
| 592 } | 606 } |
| 593 arguments.add('--checked'); | 607 arguments.add('--checked'); |
| 594 arguments.add(serverPath); | 608 arguments.add(serverPath); |
| 595 return Process.start(dartBinary, arguments).then((Process process) { | 609 return Process.start(dartBinary, arguments).then((Process process) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 */ | 753 */ |
| 740 void _recordStdio(String line) { | 754 void _recordStdio(String line) { |
| 741 double elapsedTime = _time.elapsedTicks / _time.frequency; | 755 double elapsedTime = _time.elapsedTicks / _time.frequency; |
| 742 line = "$elapsedTime: $line"; | 756 line = "$elapsedTime: $line"; |
| 743 if (_debuggingStdio) { | 757 if (_debuggingStdio) { |
| 744 print(line); | 758 print(line); |
| 745 } | 759 } |
| 746 _recordedStdio.add(line); | 760 _recordedStdio.add(line); |
| 747 } | 761 } |
| 748 } | 762 } |
| OLD | NEW |