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'; |
11 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
12 | 12 |
13 /// Will be set to the http address of the VM's service protocol before | 13 /// Will be set to the http address of the VM's service protocol before |
14 /// any tests are invoked. | 14 /// any tests are invoked. |
15 String serviceHttpAddress; | 15 String serviceHttpAddress; |
16 String serviceWebsocketAddress; | 16 String serviceWebsocketAddress; |
17 | 17 |
18 const String _TESTEE_ENV_KEY = 'SERVICE_TEST_TESTEE'; | 18 const String _TESTEE_ENV_KEY = 'SERVICE_TEST_TESTEE'; |
19 const Map<String, String> _TESTEE_SPAWN_ENV = const {_TESTEE_ENV_KEY: 'true'}; | 19 const Map<String, String> _TESTEE_SPAWN_ENV = const { |
| 20 _TESTEE_ENV_KEY: 'true' |
| 21 }; |
20 bool _isTestee() { | 22 bool _isTestee() { |
21 return Platform.environment.containsKey(_TESTEE_ENV_KEY); | 23 return Platform.environment.containsKey(_TESTEE_ENV_KEY); |
22 } | 24 } |
23 | 25 |
24 const String _SKY_SHELL_ENV_KEY = 'SERVICE_TEST_SKY_SHELL'; | 26 const String _SKY_SHELL_ENV_KEY = 'SERVICE_TEST_SKY_SHELL'; |
25 bool _shouldLaunchSkyShell() { | 27 bool _shouldLaunchSkyShell() { |
26 return Platform.environment.containsKey(_SKY_SHELL_ENV_KEY); | 28 return Platform.environment.containsKey(_SKY_SHELL_ENV_KEY); |
27 } | 29 } |
28 | |
29 String _skyShellPath() { | 30 String _skyShellPath() { |
30 return Platform.environment[_SKY_SHELL_ENV_KEY]; | 31 return Platform.environment[_SKY_SHELL_ENV_KEY]; |
31 } | 32 } |
32 | 33 |
33 class _ServiceTesteeRunner { | 34 class _ServiceTesteeRunner { |
34 Future run( | 35 Future run({testeeBefore(): null, |
35 {testeeBefore(): null, | 36 testeeConcurrent(): null, |
36 testeeConcurrent(): null, | 37 bool pause_on_start: false, |
37 bool pause_on_start: false, | 38 bool pause_on_exit: false}) async { |
38 bool pause_on_exit: false}) async { | |
39 if (!pause_on_start) { | 39 if (!pause_on_start) { |
40 if (testeeBefore != null) { | 40 if (testeeBefore != null) { |
41 var result = testeeBefore(); | 41 var result = testeeBefore(); |
42 if (result is Future) { | 42 if (result is Future) { |
43 await result; | 43 await result; |
44 } | 44 } |
45 } | 45 } |
46 print(''); // Print blank line to signal that testeeBefore has run. | 46 print(''); // Print blank line to signal that testeeBefore has run. |
47 } | 47 } |
48 if (testeeConcurrent != null) { | 48 if (testeeConcurrent != null) { |
49 var result = testeeConcurrent(); | 49 var result = testeeConcurrent(); |
50 if (result is Future) { | 50 if (result is Future) { |
51 await result; | 51 await result; |
52 } | 52 } |
53 } | 53 } |
54 if (!pause_on_exit) { | 54 if (!pause_on_exit) { |
55 // Wait around for the process to be killed. | 55 // Wait around for the process to be killed. |
56 stdin.first.then((_) => exit(0)); | 56 stdin.first.then((_) => exit(0)); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void runSync( | 60 void runSync({void testeeBeforeSync(): null, |
61 {void testeeBeforeSync(): null, | 61 void testeeConcurrentSync(): null, |
62 void testeeConcurrentSync(): null, | 62 bool pause_on_start: false, |
63 bool pause_on_start: false, | 63 bool pause_on_exit: false}) { |
64 bool pause_on_exit: false}) { | |
65 if (!pause_on_start) { | 64 if (!pause_on_start) { |
66 if (testeeBeforeSync != null) { | 65 if (testeeBeforeSync != null) { |
67 testeeBeforeSync(); | 66 testeeBeforeSync(); |
68 } | 67 } |
69 print(''); // Print blank line to signal that testeeBefore has run. | 68 print(''); // Print blank line to signal that testeeBefore has run. |
70 } | 69 } |
71 if (testeeConcurrentSync != null) { | 70 if (testeeConcurrentSync != null) { |
72 testeeConcurrentSync(); | 71 testeeConcurrentSync(); |
73 } | 72 } |
74 if (!pause_on_exit) { | 73 if (!pause_on_exit) { |
75 // Wait around for the process to be killed. | 74 // Wait around for the process to be killed. |
76 stdin.first.then((_) => exit(0)); | 75 stdin.first.then((_) => exit(0)); |
77 } | 76 } |
78 } | 77 } |
79 } | 78 } |
80 | 79 |
81 class _ServiceTesteeLauncher { | 80 class _ServiceTesteeLauncher { |
82 Process process; | 81 Process process; |
83 final List<String> args; | 82 final List<String> args; |
84 bool killedByTester = false; | 83 bool killedByTester = false; |
85 | 84 |
86 _ServiceTesteeLauncher() : args = [Platform.script.toFilePath()] {} | 85 _ServiceTesteeLauncher() : |
| 86 args = [Platform.script.toFilePath()] {} |
87 | 87 |
88 // Spawn the testee process. | 88 // Spawn the testee process. |
89 Future<Process> _spawnProcess( | 89 Future<Process> _spawnProcess(bool pause_on_start, |
90 bool pause_on_start, | 90 bool pause_on_exit, |
91 bool pause_on_exit, | 91 bool pause_on_unhandled_exceptions, |
92 bool pause_on_unhandled_exceptions, | 92 bool testeeControlsServer, |
93 bool testeeControlsServer, | 93 bool useAuthToken, |
94 bool useAuthToken, | 94 List<String> extraArgs) { |
95 List<String> extraArgs) { | |
96 assert(pause_on_start != null); | 95 assert(pause_on_start != null); |
97 assert(pause_on_exit != null); | 96 assert(pause_on_exit != null); |
98 assert(pause_on_unhandled_exceptions != null); | 97 assert(pause_on_unhandled_exceptions != null); |
99 assert(testeeControlsServer != null); | 98 assert(testeeControlsServer != null); |
100 assert(useAuthToken != null); | 99 assert(useAuthToken != null); |
101 | 100 |
102 if (_shouldLaunchSkyShell()) { | 101 if (_shouldLaunchSkyShell()) { |
103 return _spawnSkyProcess(pause_on_start, pause_on_exit, | 102 return _spawnSkyProcess(pause_on_start, |
104 pause_on_unhandled_exceptions, testeeControlsServer, extraArgs); | 103 pause_on_exit, |
| 104 pause_on_unhandled_exceptions, |
| 105 testeeControlsServer, |
| 106 extraArgs); |
105 } else { | 107 } else { |
106 return _spawnDartProcess( | 108 return _spawnDartProcess(pause_on_start, |
107 pause_on_start, | 109 pause_on_exit, |
108 pause_on_exit, | 110 pause_on_unhandled_exceptions, |
109 pause_on_unhandled_exceptions, | 111 testeeControlsServer, |
110 testeeControlsServer, | 112 useAuthToken, |
111 useAuthToken, | 113 extraArgs); |
112 extraArgs); | |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 Future<Process> _spawnDartProcess( | 117 Future<Process> _spawnDartProcess(bool pause_on_start, |
117 bool pause_on_start, | 118 bool pause_on_exit, |
118 bool pause_on_exit, | 119 bool pause_on_unhandled_exceptions, |
119 bool pause_on_unhandled_exceptions, | 120 bool testeeControlsServer, |
120 bool testeeControlsServer, | 121 bool useAuthToken, |
121 bool useAuthToken, | 122 List<String> extraArgs) { |
122 List<String> extraArgs) { | |
123 assert(!_shouldLaunchSkyShell()); | 123 assert(!_shouldLaunchSkyShell()); |
124 | 124 |
125 String dartExecutable = Platform.executable; | 125 String dartExecutable = Platform.executable; |
126 | 126 |
127 var fullArgs = []; | 127 var fullArgs = []; |
128 if (pause_on_start) { | 128 if (pause_on_start) { |
129 fullArgs.add('--pause-isolates-on-start'); | 129 fullArgs.add('--pause-isolates-on-start'); |
130 } | 130 } |
131 if (pause_on_exit) { | 131 if (pause_on_exit) { |
132 fullArgs.add('--pause-isolates-on-exit'); | 132 fullArgs.add('--pause-isolates-on-exit'); |
133 } | 133 } |
134 if (pause_on_unhandled_exceptions) { | 134 if (pause_on_unhandled_exceptions) { |
135 fullArgs.add('--pause-isolates-on-unhandled-exceptions'); | 135 fullArgs.add('--pause-isolates-on-unhandled-exceptions'); |
136 } | 136 } |
137 if (extraArgs != null) { | 137 if (extraArgs != null) { |
138 fullArgs.addAll(extraArgs); | 138 fullArgs.addAll(extraArgs); |
139 } | 139 } |
140 | 140 |
141 fullArgs.addAll(Platform.executableArguments); | 141 fullArgs.addAll(Platform.executableArguments); |
142 if (!testeeControlsServer) { | 142 if (!testeeControlsServer) { |
143 fullArgs.add('--enable-vm-service:0'); | 143 fullArgs.add('--enable-vm-service:0'); |
144 } | 144 } |
145 fullArgs.addAll(args); | 145 fullArgs.addAll(args); |
146 | 146 |
147 return _spawnCommon(dartExecutable, fullArgs, | 147 return _spawnCommon( |
148 <String, String>{'DART_SERVICE_USE_AUTH': '$useAuthToken'}); | 148 dartExecutable, |
| 149 fullArgs, |
| 150 <String, String>{ |
| 151 'DART_SERVICE_USE_AUTH': '$useAuthToken' |
| 152 }); |
149 } | 153 } |
150 | 154 |
151 Future<Process> _spawnSkyProcess( | 155 Future<Process> _spawnSkyProcess(bool pause_on_start, |
152 bool pause_on_start, | 156 bool pause_on_exit, |
153 bool pause_on_exit, | 157 bool pause_on_unhandled_exceptions, |
154 bool pause_on_unhandled_exceptions, | 158 bool testeeControlsServer, |
155 bool testeeControlsServer, | 159 List<String> extraArgs) { |
156 List<String> extraArgs) { | |
157 assert(_shouldLaunchSkyShell()); | 160 assert(_shouldLaunchSkyShell()); |
158 | 161 |
159 String dartExecutable = _skyShellPath(); | 162 String dartExecutable = _skyShellPath(); |
160 | 163 |
161 var dartFlags = []; | 164 var dartFlags = []; |
162 var fullArgs = []; | 165 var fullArgs = []; |
163 if (pause_on_start) { | 166 if (pause_on_start) { |
164 dartFlags.add('--pause_isolates_on_start'); | 167 dartFlags.add('--pause_isolates_on_start'); |
165 fullArgs.add('--start-paused'); | 168 fullArgs.add('--start-paused'); |
166 } | 169 } |
(...skipping 12 matching lines...) Expand all Loading... |
179 fullArgs.addAll(Platform.executableArguments); | 182 fullArgs.addAll(Platform.executableArguments); |
180 if (!testeeControlsServer) { | 183 if (!testeeControlsServer) { |
181 fullArgs.add('--observatory-port=0'); | 184 fullArgs.add('--observatory-port=0'); |
182 } | 185 } |
183 fullArgs.add('--dart-flags=${dartFlags.join(' ')}'); | 186 fullArgs.add('--dart-flags=${dartFlags.join(' ')}'); |
184 fullArgs.addAll(args); | 187 fullArgs.addAll(args); |
185 | 188 |
186 return _spawnCommon(dartExecutable, fullArgs, <String, String>{}); | 189 return _spawnCommon(dartExecutable, fullArgs, <String, String>{}); |
187 } | 190 } |
188 | 191 |
189 Future<Process> _spawnCommon(String executable, List<String> arguments, | 192 Future<Process> _spawnCommon(String executable, |
190 Map<String, String> dartEnvironment) { | 193 List<String> arguments, |
| 194 Map<String, String> dartEnvironment) { |
191 var environment = _TESTEE_SPAWN_ENV; | 195 var environment = _TESTEE_SPAWN_ENV; |
192 var bashEnvironment = new StringBuffer(); | 196 var bashEnvironment = new StringBuffer(); |
193 environment.forEach((k, v) => bashEnvironment.write("$k=$v ")); | 197 environment.forEach((k, v) => bashEnvironment.write("$k=$v ")); |
194 if (dartEnvironment != null) { | 198 if (dartEnvironment != null) { |
195 dartEnvironment.forEach((k, v) { | 199 dartEnvironment.forEach((k, v) { |
196 arguments.insert(0, '-D$k=$v'); | 200 arguments.insert(0, '-D$k=$v'); |
197 }); | 201 }); |
198 } | 202 } |
199 print('** Launching $bashEnvironment$executable ${arguments.join(' ')}'); | 203 print('** Launching $bashEnvironment$executable ${arguments.join(' ')}'); |
200 return Process.start(executable, arguments, environment: environment); | 204 return Process.start(executable, arguments, environment: environment); |
201 } | 205 } |
202 | 206 |
203 Future<Uri> launch( | 207 Future<Uri> launch(bool pause_on_start, |
204 bool pause_on_start, | 208 bool pause_on_exit, |
205 bool pause_on_exit, | 209 bool pause_on_unhandled_exceptions, |
206 bool pause_on_unhandled_exceptions, | 210 bool testeeControlsServer, |
207 bool testeeControlsServer, | 211 bool useAuthToken, |
208 bool useAuthToken, | 212 List<String> extraArgs) { |
209 List<String> extraArgs) { | 213 return _spawnProcess(pause_on_start, |
210 return _spawnProcess( | 214 pause_on_exit, |
211 pause_on_start, | 215 pause_on_unhandled_exceptions, |
212 pause_on_exit, | 216 testeeControlsServer, |
213 pause_on_unhandled_exceptions, | 217 useAuthToken, |
214 testeeControlsServer, | 218 extraArgs).then((p) { |
215 useAuthToken, | |
216 extraArgs).then((p) { | |
217 Completer<Uri> completer = new Completer<Uri>(); | 219 Completer<Uri> completer = new Completer<Uri>(); |
218 process = p; | 220 process = p; |
219 Uri uri; | 221 Uri uri; |
220 var blank; | 222 var blank; |
221 var first = true; | 223 var first = true; |
222 process.stdout | 224 process.stdout.transform(UTF8.decoder) |
223 .transform(UTF8.decoder) | 225 .transform(new LineSplitter()).listen((line) { |
224 .transform(new LineSplitter()) | |
225 .listen((line) { | |
226 const kObservatoryListening = 'Observatory listening on '; | 226 const kObservatoryListening = 'Observatory listening on '; |
227 if (line.startsWith(kObservatoryListening)) { | 227 if (line.startsWith(kObservatoryListening)) { |
228 uri = Uri.parse(line.substring(kObservatoryListening.length)); | 228 uri = Uri.parse(line.substring(kObservatoryListening.length)); |
229 } | 229 } |
230 if (pause_on_start || line == '') { | 230 if (pause_on_start || line == '') { |
231 // Received blank line. | 231 // Received blank line. |
232 blank = true; | 232 blank = true; |
233 } | 233 } |
234 if ((uri != null) && (blank == true) && (first == true)) { | 234 if ((uri != null) && (blank == true) && (first == true)) { |
235 completer.complete(uri); | 235 completer.complete(uri); |
236 // Stop repeat completions. | 236 // Stop repeat completions. |
237 first = false; | 237 first = false; |
238 print('** Signaled to run test queries on $uri'); | 238 print('** Signaled to run test queries on $uri'); |
239 } | 239 } |
240 print('>testee>out> $line'); | 240 print('>testee>out> $line'); |
241 }); | 241 }); |
242 process.stderr | 242 process.stderr.transform(UTF8.decoder) |
243 .transform(UTF8.decoder) | 243 .transform(new LineSplitter()).listen((line) { |
244 .transform(new LineSplitter()) | |
245 .listen((line) { | |
246 print('>testee>err> $line'); | 244 print('>testee>err> $line'); |
247 }); | 245 }); |
248 process.exitCode.then((exitCode) { | 246 process.exitCode.then((exitCode) { |
249 if ((exitCode != 0) && !killedByTester) { | 247 if ((exitCode != 0) && !killedByTester) { |
250 throw "Testee exited with $exitCode"; | 248 throw "Testee exited with $exitCode"; |
251 } | 249 } |
252 print("** Process exited"); | 250 print("** Process exited"); |
253 }); | 251 }); |
254 return completer.future; | 252 return completer.future; |
255 }); | 253 }); |
256 } | 254 } |
257 | 255 |
258 void requestExit() { | 256 void requestExit() { |
259 print('** Killing script'); | 257 print('** Killing script'); |
260 if (process.kill()) { | 258 if (process.kill()) { |
261 killedByTester = true; | 259 killedByTester = true; |
262 } | 260 } |
263 } | 261 } |
264 } | 262 } |
265 | 263 |
266 void setupAddresses(Uri serverAddress) { | 264 void setupAddresses(Uri serverAddress) { |
267 serviceWebsocketAddress = | 265 serviceWebsocketAddress = |
268 'ws://${serverAddress.authority}${serverAddress.path}ws'; | 266 'ws://${serverAddress.authority}${serverAddress.path}ws'; |
269 serviceHttpAddress = 'http://${serverAddress.authority}${serverAddress.path}'; | 267 serviceHttpAddress = |
| 268 'http://${serverAddress.authority}${serverAddress.path}'; |
270 } | 269 } |
271 | 270 |
272 class _ServiceTesterRunner { | 271 class _ServiceTesterRunner { |
273 void run( | 272 void run({List<String> mainArgs, |
274 {List<String> mainArgs, | 273 List<String> extraArgs, |
275 List<String> extraArgs, | 274 List<VMTest> vmTests, |
276 List<VMTest> vmTests, | 275 List<IsolateTest> isolateTests, |
277 List<IsolateTest> isolateTests, | 276 bool pause_on_start: false, |
278 bool pause_on_start: false, | 277 bool pause_on_exit: false, |
279 bool pause_on_exit: false, | 278 bool verbose_vm: false, |
280 bool verbose_vm: false, | 279 bool pause_on_unhandled_exceptions: false, |
281 bool pause_on_unhandled_exceptions: false, | 280 bool testeeControlsServer: false, |
282 bool testeeControlsServer: false, | 281 bool useAuthToken: false}) { |
283 bool useAuthToken: false}) { | |
284 var process = new _ServiceTesteeLauncher(); | 282 var process = new _ServiceTesteeLauncher(); |
285 bool testsDone = false; | 283 bool testsDone = false; |
286 runZoned(() { | 284 runZoned(() { |
287 process | 285 process.launch(pause_on_start, pause_on_exit, |
288 .launch(pause_on_start, pause_on_exit, pause_on_unhandled_exceptions, | 286 pause_on_unhandled_exceptions, |
289 testeeControlsServer, useAuthToken, extraArgs) | 287 testeeControlsServer, |
290 .then((Uri serverAddress) async { | 288 useAuthToken, extraArgs).then((Uri serverAddress) async { |
291 if (mainArgs.contains("--gdb")) { | 289 if (mainArgs.contains("--gdb")) { |
292 var pid = process.process.pid; | 290 var pid = process.process.pid; |
293 var wait = new Duration(seconds: 10); | 291 var wait = new Duration(seconds: 10); |
294 print("Testee has pid $pid, waiting $wait before continuing"); | 292 print("Testee has pid $pid, waiting $wait before continuing"); |
295 sleep(wait); | 293 sleep(wait); |
296 } | 294 } |
297 setupAddresses(serverAddress); | 295 setupAddresses(serverAddress); |
298 var name = Platform.script.pathSegments.last; | 296 var name = Platform.script.pathSegments.last; |
299 var vm = | 297 var vm = |
300 new WebSocketVM(new WebSocketVMTarget(serviceWebsocketAddress)); | 298 new WebSocketVM(new WebSocketVMTarget(serviceWebsocketAddress)); |
(...skipping 26 matching lines...) Expand all Loading... |
327 } | 325 } |
328 } | 326 } |
329 | 327 |
330 print('All service tests completed successfully.'); | 328 print('All service tests completed successfully.'); |
331 testsDone = true; | 329 testsDone = true; |
332 await process.requestExit(); | 330 await process.requestExit(); |
333 }); | 331 }); |
334 }, onError: (error, stackTrace) async { | 332 }, onError: (error, stackTrace) async { |
335 if (testsDone) { | 333 if (testsDone) { |
336 print('Ignoring late exception during process exit:\n' | 334 print('Ignoring late exception during process exit:\n' |
337 '$error\n#stackTrace'); | 335 '$error\n#stackTrace'); |
338 } else { | 336 } else { |
339 await process.requestExit(); | 337 await process.requestExit(); |
340 print('Unexpected exception in service tests: $error\n$stackTrace'); | 338 print('Unexpected exception in service tests: $error\n$stackTrace'); |
341 throw error; | 339 throw error; |
342 } | 340 } |
343 }); | 341 }); |
344 } | 342 } |
345 | 343 |
346 Future<Isolate> getFirstIsolate(WebSocketVM vm) async { | 344 Future<Isolate> getFirstIsolate(WebSocketVM vm) async { |
347 if (vm.isolates.isNotEmpty) { | 345 if (vm.isolates.isNotEmpty) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 }); | 381 }); |
384 } | 382 } |
385 return await completer.future; | 383 return await completer.future; |
386 } | 384 } |
387 } | 385 } |
388 | 386 |
389 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 387 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
390 /// return a [Future]. Code for setting up state can run before and/or | 388 /// return a [Future]. Code for setting up state can run before and/or |
391 /// concurrently with the tests. Uses [mainArgs] to determine whether | 389 /// concurrently with the tests. Uses [mainArgs] to determine whether |
392 /// to run tests or testee in this invokation of the script. | 390 /// to run tests or testee in this invokation of the script. |
393 Future runIsolateTests(List<String> mainArgs, List<IsolateTest> tests, | 391 Future runIsolateTests(List<String> mainArgs, |
394 {testeeBefore(), | 392 List<IsolateTest> tests, |
395 testeeConcurrent(), | 393 {testeeBefore(), |
396 bool pause_on_start: false, | 394 testeeConcurrent(), |
397 bool pause_on_exit: false, | 395 bool pause_on_start: false, |
398 bool verbose_vm: false, | 396 bool pause_on_exit: false, |
399 bool pause_on_unhandled_exceptions: false, | 397 bool verbose_vm: false, |
400 bool testeeControlsServer: false, | 398 bool pause_on_unhandled_exceptions: false, |
401 bool useAuthToken: false, | 399 bool testeeControlsServer: false, |
402 List<String> extraArgs}) async { | 400 bool useAuthToken: false, |
| 401 List<String> extraArgs}) async { |
403 assert(!pause_on_start || testeeBefore == null); | 402 assert(!pause_on_start || testeeBefore == null); |
404 if (_isTestee()) { | 403 if (_isTestee()) { |
405 new _ServiceTesteeRunner().run( | 404 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore, |
406 testeeBefore: testeeBefore, | 405 testeeConcurrent: testeeConcurrent, |
407 testeeConcurrent: testeeConcurrent, | 406 pause_on_start: pause_on_start, |
408 pause_on_start: pause_on_start, | 407 pause_on_exit: pause_on_exit); |
409 pause_on_exit: pause_on_exit); | |
410 } else { | 408 } else { |
411 new _ServiceTesterRunner().run( | 409 new _ServiceTesterRunner().run( |
412 mainArgs: mainArgs, | 410 mainArgs: mainArgs, |
413 extraArgs: extraArgs, | 411 extraArgs: extraArgs, |
414 isolateTests: tests, | 412 isolateTests: tests, |
415 pause_on_start: pause_on_start, | 413 pause_on_start: pause_on_start, |
416 pause_on_exit: pause_on_exit, | 414 pause_on_exit: pause_on_exit, |
417 verbose_vm: verbose_vm, | 415 verbose_vm: verbose_vm, |
418 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions, | 416 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions, |
419 testeeControlsServer: testeeControlsServer, | 417 testeeControlsServer: testeeControlsServer, |
420 useAuthToken: useAuthToken); | 418 useAuthToken: useAuthToken); |
421 } | 419 } |
422 } | 420 } |
423 | 421 |
424 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 422 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
425 /// return a [Future]. Code for setting up state can run before and/or | 423 /// return a [Future]. Code for setting up state can run before and/or |
426 /// concurrently with the tests. Uses [mainArgs] to determine whether | 424 /// concurrently with the tests. Uses [mainArgs] to determine whether |
427 /// to run tests or testee in this invokation of the script. | 425 /// to run tests or testee in this invokation of the script. |
428 /// | 426 /// |
429 /// This is a special version of this test harness specifically for the | 427 /// This is a special version of this test harness specifically for the |
430 /// pause_on_unhandled_exceptions_test, which cannot properly function | 428 /// pause_on_unhandled_exceptions_test, which cannot properly function |
431 /// in an async context (because exceptions are *always* handled in async | 429 /// in an async context (because exceptions are *always* handled in async |
432 /// functions). | 430 /// functions). |
433 void runIsolateTestsSynchronous(List<String> mainArgs, List<IsolateTest> tests, | 431 void runIsolateTestsSynchronous(List<String> mainArgs, |
434 {void testeeBefore(), | 432 List<IsolateTest> tests, |
435 void testeeConcurrent(), | 433 {void testeeBefore(), |
436 bool pause_on_start: false, | 434 void testeeConcurrent(), |
437 bool pause_on_exit: false, | 435 bool pause_on_start: false, |
438 bool verbose_vm: false, | 436 bool pause_on_exit: false, |
439 bool pause_on_unhandled_exceptions: false, | 437 bool verbose_vm: false, |
440 List<String> extraArgs}) { | 438 bool pause_on_unhandled_exceptions: false, |
| 439 List<String> extraArgs}) { |
441 assert(!pause_on_start || testeeBefore == null); | 440 assert(!pause_on_start || testeeBefore == null); |
442 if (_isTestee()) { | 441 if (_isTestee()) { |
443 new _ServiceTesteeRunner().runSync( | 442 new _ServiceTesteeRunner().runSync(testeeBeforeSync: testeeBefore, |
444 testeeBeforeSync: testeeBefore, | 443 testeeConcurrentSync: testeeConcurrent, |
445 testeeConcurrentSync: testeeConcurrent, | 444 pause_on_start: pause_on_start, |
446 pause_on_start: pause_on_start, | 445 pause_on_exit: pause_on_exit); |
447 pause_on_exit: pause_on_exit); | |
448 } else { | 446 } else { |
449 new _ServiceTesterRunner().run( | 447 new _ServiceTesterRunner().run( |
450 mainArgs: mainArgs, | 448 mainArgs: mainArgs, |
451 extraArgs: extraArgs, | 449 extraArgs: extraArgs, |
452 isolateTests: tests, | 450 isolateTests: tests, |
453 pause_on_start: pause_on_start, | 451 pause_on_start: pause_on_start, |
454 pause_on_exit: pause_on_exit, | 452 pause_on_exit: pause_on_exit, |
455 verbose_vm: verbose_vm, | 453 verbose_vm: verbose_vm, |
456 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); | 454 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); |
457 } | 455 } |
458 } | 456 } |
459 | 457 |
| 458 |
460 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 459 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
461 /// return a [Future]. Code for setting up state can run before and/or | 460 /// return a [Future]. Code for setting up state can run before and/or |
462 /// concurrently with the tests. Uses [mainArgs] to determine whether | 461 /// concurrently with the tests. Uses [mainArgs] to determine whether |
463 /// to run tests or testee in this invokation of the script. | 462 /// to run tests or testee in this invokation of the script. |
464 Future runVMTests(List<String> mainArgs, List<VMTest> tests, | 463 Future runVMTests(List<String> mainArgs, |
465 {testeeBefore(), | 464 List<VMTest> tests, |
466 testeeConcurrent(), | 465 {testeeBefore(), |
467 bool pause_on_start: false, | 466 testeeConcurrent(), |
468 bool pause_on_exit: false, | 467 bool pause_on_start: false, |
469 bool verbose_vm: false, | 468 bool pause_on_exit: false, |
470 bool pause_on_unhandled_exceptions: false, | 469 bool verbose_vm: false, |
471 List<String> extraArgs}) async { | 470 bool pause_on_unhandled_exceptions: false, |
| 471 List<String> extraArgs}) async { |
472 if (_isTestee()) { | 472 if (_isTestee()) { |
473 new _ServiceTesteeRunner().run( | 473 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore, |
474 testeeBefore: testeeBefore, | 474 testeeConcurrent: testeeConcurrent, |
475 testeeConcurrent: testeeConcurrent, | 475 pause_on_start: pause_on_start, |
476 pause_on_start: pause_on_start, | 476 pause_on_exit: pause_on_exit); |
477 pause_on_exit: pause_on_exit); | |
478 } else { | 477 } else { |
479 new _ServiceTesterRunner().run( | 478 new _ServiceTesterRunner().run( |
480 mainArgs: mainArgs, | 479 mainArgs: mainArgs, |
481 extraArgs: extraArgs, | 480 extraArgs: extraArgs, |
482 vmTests: tests, | 481 vmTests: tests, |
483 pause_on_start: pause_on_start, | 482 pause_on_start: pause_on_start, |
484 pause_on_exit: pause_on_exit, | 483 pause_on_exit: pause_on_exit, |
485 verbose_vm: verbose_vm, | 484 verbose_vm: verbose_vm, |
486 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); | 485 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); |
487 } | 486 } |
488 } | 487 } |
OLD | NEW |