| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_helper; | 5 library test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 import 'package:observatory/service_io.dart'; | 11 import 'package:observatory/service_io.dart'; |
| 12 | 12 |
| 13 // This invocation should set up the state being tested. | 13 // This invocation should set up the state being tested. |
| 14 const String _TESTEE_MODE_FLAG = "--testee-mode"; | 14 const String _TESTEE_MODE_FLAG = "--testee-mode"; |
| 15 | 15 |
| 16 class _TestLauncher { | 16 class _TestLauncher { |
| 17 Process process; | 17 Process process; |
| 18 final List<String> args; | 18 final List<String> args; |
| 19 | 19 |
| 20 _TestLauncher() : args = ['--enable-vm-service:0', | 20 _TestLauncher() : args = ['--enable-vm-service:0', |
| 21 Platform.script.toFilePath(), | 21 Platform.script.toFilePath(), |
| 22 _TESTEE_MODE_FLAG] {} | 22 _TESTEE_MODE_FLAG] {} |
| 23 | 23 |
| 24 Future<int> launch() { | 24 Future<int> launch() { |
| 25 String dartExecutable = Platform.executable; | 25 String dartExecutable = Platform.executable; |
| 26 print('** Launching $args'); | 26 var fullArgs = []; |
| 27 return Process.start(dartExecutable, args).then((p) { | 27 fullArgs.addAll(Platform.executableArguments); |
| 28 fullArgs.addAll(args); |
| 29 print('** Launching $fullArgs'); |
| 30 return Process.start(dartExecutable, fullArgs).then((p) { |
| 28 | 31 |
| 29 Completer completer = new Completer(); | 32 Completer completer = new Completer(); |
| 30 process = p; | 33 process = p; |
| 31 var portNumber; | 34 var portNumber; |
| 32 var blank; | 35 var blank; |
| 33 var first = true; | 36 var first = true; |
| 34 process.stdout.transform(UTF8.decoder) | 37 process.stdout.transform(UTF8.decoder) |
| 35 .transform(new LineSplitter()).listen((line) { | 38 .transform(new LineSplitter()).listen((line) { |
| 36 if (line.startsWith('Observatory listening on http://')) { | 39 if (line.startsWith('Observatory listening on http://')) { |
| 37 RegExp portExp = new RegExp(r"\d+.\d+.\d+.\d+:(\d+)"); | 40 RegExp portExp = new RegExp(r"\d+.\d+.\d+.\d+:(\d+)"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 process.launch().then((port) { | 95 process.launch().then((port) { |
| 93 String addr = 'ws://localhost:$port/ws'; | 96 String addr = 'ws://localhost:$port/ws'; |
| 94 new WebSocketVM(new WebSocketVMTarget(addr)).get('vm') | 97 new WebSocketVM(new WebSocketVMTarget(addr)).get('vm') |
| 95 .then((VM vm) => vm.isolates.first.load()) | 98 .then((VM vm) => vm.isolates.first.load()) |
| 96 .then((Isolate isolate) => | 99 .then((Isolate isolate) => |
| 97 Future.forEach(tests, (test) => test(isolate))) | 100 Future.forEach(tests, (test) => test(isolate))) |
| 98 .then((_) => exit(0)); | 101 .then((_) => exit(0)); |
| 99 }); | 102 }); |
| 100 } | 103 } |
| 101 } | 104 } |
| OLD | NEW |