| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 * Start the server. If [debugServer] is true, the server will be started | 504 * Start the server. If [debugServer] is true, the server will be started |
| 505 * with "--debug", allowing a debugger to be attached. | 505 * with "--debug", allowing a debugger to be attached. |
| 506 */ | 506 */ |
| 507 static Future<Server> start({bool debugServer: false}) { | 507 static Future<Server> start({bool debugServer: false}) { |
| 508 // TODO(paulberry): move the logic for finding the script, the dart | 508 // TODO(paulberry): move the logic for finding the script, the dart |
| 509 // executable, and the package root into a shell script. | 509 // executable, and the package root into a shell script. |
| 510 String dartBinary = Platform.executable; | 510 String dartBinary = Platform.executable; |
| 511 String scriptDir = dirname(Platform.script.path); | 511 String scriptDir = dirname(Platform.script.path); |
| 512 String serverPath = normalize(join(scriptDir, '..', '..', 'bin', | 512 String serverPath = normalize(join(scriptDir, '..', '..', 'bin', |
| 513 'server.dart')); | 513 'server.dart')); |
| 514 String repoPath = normalize(join(scriptDir, '..', '..', '..', '..')); | |
| 515 String buildDirName; | |
| 516 if (Platform.isWindows) { | |
| 517 buildDirName = 'build'; | |
| 518 } else if (Platform.isMacOS) { | |
| 519 buildDirName = 'xcodebuild'; | |
| 520 } else { | |
| 521 buildDirName = 'out'; | |
| 522 } | |
| 523 // TODO(paulberry): this is a guess | |
| 524 String dartConfiguration = 'ReleaseIA32'; | |
| 525 String buildPath = join(repoPath, buildDirName, dartConfiguration); | |
| 526 String packageRoot = join(buildPath, 'packages'); | |
| 527 List<String> arguments = []; | 514 List<String> arguments = []; |
| 528 if (debugServer) { | 515 if (debugServer) { |
| 529 arguments.add('--debug'); | 516 arguments.add('--debug'); |
| 530 } | 517 } |
| 531 arguments.add('--package-root=$packageRoot'); | 518 arguments.add('--package-root=${Platform.packageRoot}'); |
| 532 arguments.add(serverPath); | 519 arguments.add(serverPath); |
| 533 return Process.start(dartBinary, arguments).then((Process process) { | 520 return Process.start(dartBinary, arguments).then((Process process) { |
| 534 Server server = new Server._(process); | 521 Server server = new Server._(process); |
| 535 process.stdout.transform((new Utf8Codec()).decoder).transform( | 522 process.stdout.transform((new Utf8Codec()).decoder).transform( |
| 536 new LineSplitter()).listen((String line) { | 523 new LineSplitter()).listen((String line) { |
| 537 String trimmedLine = line.trim(); | 524 String trimmedLine = line.trim(); |
| 538 server._recordStdio('RECV: $trimmedLine'); | 525 server._recordStdio('RECV: $trimmedLine'); |
| 539 var message; | 526 var message; |
| 540 try { | 527 try { |
| 541 message = JSON.decoder.convert(trimmedLine); | 528 message = JSON.decoder.convert(trimmedLine); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 * Record a message that was exchanged with the server, and print it out if | 650 * Record a message that was exchanged with the server, and print it out if |
| 664 * [debugStdio] has been called. | 651 * [debugStdio] has been called. |
| 665 */ | 652 */ |
| 666 void _recordStdio(String line) { | 653 void _recordStdio(String line) { |
| 667 if (_debuggingStdio) { | 654 if (_debuggingStdio) { |
| 668 print(line); | 655 print(line); |
| 669 } | 656 } |
| 670 _recordedStdio.add(line); | 657 _recordedStdio.add(line); |
| 671 } | 658 } |
| 672 } | 659 } |
| OLD | NEW |