| 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked |
| 5 | 5 |
| 6 library test_helper; | 6 library test_helper; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 Future processServiceEvents(VM vm, ServiceEventHandler handler) { | 144 Future processServiceEvents(VM vm, ServiceEventHandler handler) { |
| 145 Completer completer = new Completer(); | 145 Completer completer = new Completer(); |
| 146 var subscription; | 146 var subscription; |
| 147 subscription = vm.events.stream.listen((ServiceEvent event) { | 147 subscription = vm.events.stream.listen((ServiceEvent event) { |
| 148 handler(event, subscription, completer); | 148 handler(event, subscription, completer); |
| 149 }); | 149 }); |
| 150 return completer.future; | 150 return completer.future; |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) { |
| 155 if ((isolate.pauseEvent != null) && |
| 156 (isolate.pauseEvent.eventType == ServiceEvent.kPauseBreakpoint)) { |
| 157 // Already waiting at a breakpoint. |
| 158 print('Breakpoint reached'); |
| 159 return new Future.value(isolate); |
| 160 } |
| 161 |
| 162 // Set up a listener to wait for breakpoint events. |
| 163 Completer completer = new Completer(); |
| 164 var subscription; |
| 165 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 166 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| 167 print('Breakpoint reached'); |
| 168 subscription.cancel(); |
| 169 completer.complete(isolate); |
| 170 } |
| 171 }); |
| 172 |
| 173 return completer.future; // Will complete when breakpoint hit. |
| 174 } |
| 175 |
| 154 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 176 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
| 155 /// return a [Future]. Code for setting up state can run before and/or | 177 /// return a [Future]. Code for setting up state can run before and/or |
| 156 /// concurrently with the tests. Uses [mainArgs] to determine whether | 178 /// concurrently with the tests. Uses [mainArgs] to determine whether |
| 157 /// to run tests or testee in this invokation of the script. | 179 /// to run tests or testee in this invokation of the script. |
| 158 Future runVMTests(List<String> mainArgs, | 180 Future runVMTests(List<String> mainArgs, |
| 159 List<VMTest> tests, | 181 List<VMTest> tests, |
| 160 {Future testeeBefore(), | 182 {Future testeeBefore(), |
| 161 Future testeeConcurrent(), | 183 Future testeeConcurrent(), |
| 162 bool pause_on_exit}) async { | 184 bool pause_on_exit}) async { |
| 163 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { | 185 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 187 }, onError: (e, st) { | 209 }, onError: (e, st) { |
| 188 process.requestExit(); | 210 process.requestExit(); |
| 189 if (!_isWebSocketDisconnect(e)) { | 211 if (!_isWebSocketDisconnect(e)) { |
| 190 print('Unexpected exception in service tests: $e $st'); | 212 print('Unexpected exception in service tests: $e $st'); |
| 191 throw e; | 213 throw e; |
| 192 } | 214 } |
| 193 }); | 215 }); |
| 194 }); | 216 }); |
| 195 } | 217 } |
| 196 } | 218 } |
| OLD | NEW |