Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: runtime/observatory/tests/service/test_helper.dart

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

Powered by Google App Engine
This is Rietveld 408576698