| 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 vmservice_test_helper; | 5 library vmservice_test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; |
| 8 import 'dart:io'; | 9 import 'dart:io'; |
| 9 import 'dart:json' as JSON; | 10 import 'dart:json' as JSON; |
| 10 import 'dart:utf' as UTF; | 11 import 'dart:utf' as UTF; |
| 11 import 'package:expect/expect.dart'; | 12 import 'package:expect/expect.dart'; |
| 12 | 13 |
| 13 abstract class VmServiceRequestHelper { | 14 abstract class VmServiceRequestHelper { |
| 14 final Uri uri; | 15 final Uri uri; |
| 15 final HttpClient client; | 16 final HttpClient client; |
| 16 | 17 |
| 17 VmServiceRequestHelper(String url) : | 18 VmServiceRequestHelper(String url) : |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 print('** Launching $scriptPath'); | 91 print('** Launching $scriptPath'); |
| 91 return Process.start(dartExecutable, | 92 return Process.start(dartExecutable, |
| 92 ['--enable-vm-service:0', scriptPath]).then((p) { | 93 ['--enable-vm-service:0', scriptPath]).then((p) { |
| 93 | 94 |
| 94 Completer completer = new Completer(); | 95 Completer completer = new Completer(); |
| 95 process = p; | 96 process = p; |
| 96 var portNumber; | 97 var portNumber; |
| 97 var blank; | 98 var blank; |
| 98 var first = true; | 99 var first = true; |
| 99 process.stdout.transform(new StringDecoder()) | 100 process.stdout.transform(new StringDecoder()) |
| 100 .transform(new LineTransformer()).listen((line) { | 101 .transform(new LineSplitter()).listen((line) { |
| 101 if (line.startsWith('VmService listening on port ')) { | 102 if (line.startsWith('VmService listening on port ')) { |
| 102 RegExp portExp = new RegExp(r"\d+"); | 103 RegExp portExp = new RegExp(r"\d+"); |
| 103 var port = portExp.stringMatch(line); | 104 var port = portExp.stringMatch(line); |
| 104 portNumber = int.parse(port); | 105 portNumber = int.parse(port); |
| 105 } | 106 } |
| 106 if (line == '') { | 107 if (line == '') { |
| 107 // Received blank line. | 108 // Received blank line. |
| 108 blank = true; | 109 blank = true; |
| 109 } | 110 } |
| 110 if (portNumber != null && blank == true && first == true) { | 111 if (portNumber != null && blank == true && first == true) { |
| 111 completer.complete(portNumber); | 112 completer.complete(portNumber); |
| 112 // Stop repeat completions. | 113 // Stop repeat completions. |
| 113 first = false; | 114 first = false; |
| 114 print('** Signaled to run test queries on $portNumber'); | 115 print('** Signaled to run test queries on $portNumber'); |
| 115 } | 116 } |
| 116 print(line); | 117 print(line); |
| 117 }); | 118 }); |
| 118 process.stderr.transform(new StringDecoder()) | 119 process.stderr.transform(new StringDecoder()) |
| 119 .transform(new LineTransformer()).listen((line) { | 120 .transform(new LineSplitter()).listen((line) { |
| 120 print(line); | 121 print(line); |
| 121 }); | 122 }); |
| 122 process.exitCode.then((code) { | 123 process.exitCode.then((code) { |
| 123 Expect.equals(0, code, 'Launched dart executable exited with error.'); | 124 Expect.equals(0, code, 'Launched dart executable exited with error.'); |
| 124 }); | 125 }); |
| 125 return completer.future; | 126 return completer.future; |
| 126 }); | 127 }); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void requestExit() { | 130 void requestExit() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (isolate['id'] == id) { | 174 if (isolate['id'] == id) { |
| 174 exists = true; | 175 exists = true; |
| 175 Expect.isTrue(isolate['name'].startsWith(name), | 176 Expect.isTrue(isolate['name'].startsWith(name), |
| 176 'Isolate $id does not have name prefix: $name' | 177 'Isolate $id does not have name prefix: $name' |
| 177 ' (was ${isolate['name']})'); | 178 ' (was ${isolate['name']})'); |
| 178 } | 179 } |
| 179 }); | 180 }); |
| 180 Expect.isTrue(exists, 'No isolate with id: $id'); | 181 Expect.isTrue(exists, 'No isolate with id: $id'); |
| 181 } | 182 } |
| 182 } | 183 } |
| OLD | NEW |