| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 _notificationStreams[event] = notificationStream; | 487 _notificationStreams[event] = notificationStream; |
| 488 } | 488 } |
| 489 return notificationStream; | 489 return notificationStream; |
| 490 } | 490 } |
| 491 | 491 |
| 492 /** | 492 /** |
| 493 * Start the server. If [debugServer] is true, the server will be started | 493 * Start the server. If [debugServer] is true, the server will be started |
| 494 * with "--debug", allowing a debugger to be attached. | 494 * with "--debug", allowing a debugger to be attached. |
| 495 */ | 495 */ |
| 496 static Future<Server> start({bool debugServer: false}) { | 496 static Future<Server> start({bool debugServer: false}) { |
| 497 // TODO(paulberry): move the logic for finding the script, the dart |
| 498 // executable, and the package root into a shell script. |
| 497 String dartBinary = Platform.executable; | 499 String dartBinary = Platform.executable; |
| 498 String serverPath = normalize(join(dirname(Platform.script.path), '..', | 500 String scriptDir = dirname(Platform.script.path); |
| 501 String serverPath = normalize(join(scriptDir, '..', |
| 499 '..', 'bin', 'server.dart')); | 502 '..', 'bin', 'server.dart')); |
| 503 String repoPath = normalize(join(scriptDir, '..', '..', '..', '..')); |
| 504 String buildDirName; |
| 505 if (Platform.isWindows) { |
| 506 buildDirName = 'build'; |
| 507 } else if (Platform.isMacOS){ |
| 508 buildDirName = 'xcodebuild'; |
| 509 } else { |
| 510 buildDirName = 'out'; |
| 511 } |
| 512 String dartConfiguration = 'ReleaseIA32'; // TODO(paulberry): this is a gues
s |
| 513 String buildPath = join(repoPath, buildDirName, dartConfiguration); |
| 514 String packageRoot = join(buildPath, 'packages'); |
| 500 List<String> arguments = []; | 515 List<String> arguments = []; |
| 501 if (debugServer) { | 516 if (debugServer) { |
| 502 arguments.add('--debug'); | 517 arguments.add('--debug'); |
| 503 } | 518 } |
| 519 arguments.add('--package-root=$packageRoot'); |
| 504 arguments.add(serverPath); | 520 arguments.add(serverPath); |
| 505 return Process.start(dartBinary, arguments).then((Process process) { | 521 return Process.start(dartBinary, arguments).then((Process process) { |
| 506 Server server = new Server._(process); | 522 Server server = new Server._(process); |
| 507 process.stdout.transform((new Utf8Codec()).decoder).transform( | 523 process.stdout.transform((new Utf8Codec()).decoder).transform( |
| 508 new LineSplitter()).listen((String line) { | 524 new LineSplitter()).listen((String line) { |
| 509 String trimmedLine = line.trim(); | 525 String trimmedLine = line.trim(); |
| 510 server._recordStdio('RECV: $trimmedLine'); | 526 server._recordStdio('RECV: $trimmedLine'); |
| 511 var message = JSON.decoder.convert(trimmedLine); | 527 var message = JSON.decoder.convert(trimmedLine); |
| 512 expect(message, isMap); | 528 expect(message, isMap); |
| 513 Map messageAsMap = message; | 529 Map messageAsMap = message; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 * Record a message that was exchanged with the server, and print it out if | 622 * Record a message that was exchanged with the server, and print it out if |
| 607 * [debugStdio] has been called. | 623 * [debugStdio] has been called. |
| 608 */ | 624 */ |
| 609 void _recordStdio(String line) { | 625 void _recordStdio(String line) { |
| 610 if (_debuggingStdio) { | 626 if (_debuggingStdio) { |
| 611 print(line); | 627 print(line); |
| 612 } | 628 } |
| 613 _recordedStdio.add(line); | 629 _recordedStdio.add(line); |
| 614 } | 630 } |
| 615 } | 631 } |
| OLD | NEW |