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:observatory/service_io.dart'; | 10 import 'package:observatory/service_io.dart'; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 102 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
103 /// return a [Future]. Code for setting up state can run before and/or | 103 /// return a [Future]. Code for setting up state can run before and/or |
104 /// concurrently with the tests. Uses [mainArgs] to determine whether | 104 /// concurrently with the tests. Uses [mainArgs] to determine whether |
105 /// to run tests or testee in this invokation of the script. | 105 /// to run tests or testee in this invokation of the script. |
106 void runIsolateTests(List<String> mainArgs, | 106 void runIsolateTests(List<String> mainArgs, |
107 List<IsolateTest> tests, | 107 List<IsolateTest> tests, |
108 {void testeeBefore(), | 108 {void testeeBefore(), |
109 void testeeConcurrent(), | 109 void testeeConcurrent(), |
110 bool pause_on_start: false, | 110 bool pause_on_start: false, |
111 bool pause_on_exit: false, | 111 bool pause_on_exit: false, |
112 bool trace_service: false}) { | 112 bool trace_service: false, |
| 113 bool verbose_vm: false}) { |
113 assert(!pause_on_start || testeeBefore == null); | 114 assert(!pause_on_start || testeeBefore == null); |
114 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { | 115 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { |
115 if (!pause_on_start) { | 116 if (!pause_on_start) { |
116 if (testeeBefore != null) { | 117 if (testeeBefore != null) { |
117 testeeBefore(); | 118 testeeBefore(); |
118 } | 119 } |
119 print(''); // Print blank line to signal that we are ready. | 120 print(''); // Print blank line to signal that we are ready. |
120 } | 121 } |
121 if (testeeConcurrent != null) { | 122 if (testeeConcurrent != null) { |
122 testeeConcurrent(); | 123 testeeConcurrent(); |
(...skipping 10 matching lines...) Expand all Loading... |
133 } | 134 } |
134 String addr = 'ws://localhost:$port/ws'; | 135 String addr = 'ws://localhost:$port/ws'; |
135 serviceHttpAddress = 'http://localhost:$port'; | 136 serviceHttpAddress = 'http://localhost:$port'; |
136 var testIndex = 1; | 137 var testIndex = 1; |
137 var totalTests = tests.length; | 138 var totalTests = tests.length; |
138 var name = Platform.script.pathSegments.last; | 139 var name = Platform.script.pathSegments.last; |
139 runZoned(() { | 140 runZoned(() { |
140 new WebSocketVM(new WebSocketVMTarget(addr)).load() | 141 new WebSocketVM(new WebSocketVMTarget(addr)).load() |
141 .then((VM vm) => vm.isolates.first.load()) | 142 .then((VM vm) => vm.isolates.first.load()) |
142 .then((Isolate isolate) => Future.forEach(tests, (test) { | 143 .then((Isolate isolate) => Future.forEach(tests, (test) { |
| 144 isolate.vm.verbose = verbose_vm; |
143 print('Running $name [$testIndex/$totalTests]'); | 145 print('Running $name [$testIndex/$totalTests]'); |
144 testIndex++; | 146 testIndex++; |
145 return test(isolate); | 147 return test(isolate); |
146 })).then((_) => process.requestExit()); | 148 })).then((_) => process.requestExit()); |
147 }, onError: (e, st) { | 149 }, onError: (e, st) { |
148 process.requestExit(); | 150 process.requestExit(); |
149 if (!_isWebSocketDisconnect(e)) { | 151 if (!_isWebSocketDisconnect(e)) { |
150 print('Unexpected exception in service tests: $e $st'); | 152 print('Unexpected exception in service tests: $e $st'); |
151 throw e; | 153 throw e; |
152 } | 154 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 280 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
279 /// return a [Future]. Code for setting up state can run before and/or | 281 /// return a [Future]. Code for setting up state can run before and/or |
280 /// concurrently with the tests. Uses [mainArgs] to determine whether | 282 /// concurrently with the tests. Uses [mainArgs] to determine whether |
281 /// to run tests or testee in this invokation of the script. | 283 /// to run tests or testee in this invokation of the script. |
282 Future runVMTests(List<String> mainArgs, | 284 Future runVMTests(List<String> mainArgs, |
283 List<VMTest> tests, | 285 List<VMTest> tests, |
284 {Future testeeBefore(), | 286 {Future testeeBefore(), |
285 Future testeeConcurrent(), | 287 Future testeeConcurrent(), |
286 bool pause_on_start: false, | 288 bool pause_on_start: false, |
287 bool pause_on_exit: false, | 289 bool pause_on_exit: false, |
288 bool trace_service: false}) async { | 290 bool trace_service: false, |
| 291 bool verbose_vm: false}) async { |
289 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { | 292 if (mainArgs.contains(_TESTEE_MODE_FLAG)) { |
290 if (!pause_on_start) { | 293 if (!pause_on_start) { |
291 if (testeeBefore != null) { | 294 if (testeeBefore != null) { |
292 await testeeBefore(); | 295 await testeeBefore(); |
293 } | 296 } |
294 print(''); // Print blank line to signal that we are ready. | 297 print(''); // Print blank line to signal that we are ready. |
295 } | 298 } |
296 if (testeeConcurrent != null) { | 299 if (testeeConcurrent != null) { |
297 await testeeConcurrent(); | 300 await testeeConcurrent(); |
298 } | 301 } |
(...skipping 10 matching lines...) Expand all Loading... |
309 port = 8181; | 312 port = 8181; |
310 } | 313 } |
311 String addr = 'ws://localhost:$port/ws'; | 314 String addr = 'ws://localhost:$port/ws'; |
312 serviceHttpAddress = 'http://localhost:$port'; | 315 serviceHttpAddress = 'http://localhost:$port'; |
313 var testIndex = 1; | 316 var testIndex = 1; |
314 var totalTests = tests.length; | 317 var totalTests = tests.length; |
315 var name = Platform.script.pathSegments.last; | 318 var name = Platform.script.pathSegments.last; |
316 runZoned(() { | 319 runZoned(() { |
317 new WebSocketVM(new WebSocketVMTarget(addr)).load() | 320 new WebSocketVM(new WebSocketVMTarget(addr)).load() |
318 .then((VM vm) => Future.forEach(tests, (test) { | 321 .then((VM vm) => Future.forEach(tests, (test) { |
| 322 vm.verbose = verbose_vm; |
319 print('Running $name [$testIndex/$totalTests]'); | 323 print('Running $name [$testIndex/$totalTests]'); |
320 testIndex++; | 324 testIndex++; |
321 return test(vm); | 325 return test(vm); |
322 })).then((_) => process.requestExit()); | 326 })).then((_) => process.requestExit()); |
323 }, onError: (e, st) { | 327 }, onError: (e, st) { |
324 process.requestExit(); | 328 process.requestExit(); |
325 if (!_isWebSocketDisconnect(e)) { | 329 if (!_isWebSocketDisconnect(e)) { |
326 print('Unexpected exception in service tests: $e $st'); | 330 print('Unexpected exception in service tests: $e $st'); |
327 throw e; | 331 throw e; |
328 } | 332 } |
329 }); | 333 }); |
330 }); | 334 }); |
331 } | 335 } |
332 } | 336 } |
OLD | NEW |