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

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

Issue 2680303002: Kernel debugging; service tests (Closed)
Patch Set: New failing test Created 3 years, 10 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';
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 for (var test in vmTests) { 308 for (var test in vmTests) {
309 vm.verbose = verbose_vm; 309 vm.verbose = verbose_vm;
310 print('Running $name [$testIndex/$totalTests]'); 310 print('Running $name [$testIndex/$totalTests]');
311 testIndex++; 311 testIndex++;
312 await test(vm); 312 await test(vm);
313 } 313 }
314 } 314 }
315 315
316 // Run isolate tests. 316 // Run isolate tests.
317 if (isolateTests != null) { 317 if (isolateTests != null) {
318 var isolate = await vm.isolates.first.load(); 318 var isolate = await getIsolate(vm);
319 var testIndex = 1; 319 var testIndex = 1;
320 var totalTests = isolateTests.length; 320 var totalTests = isolateTests.length;
321 for (var test in isolateTests) { 321 for (var test in isolateTests) {
322 vm.verbose = verbose_vm; 322 vm.verbose = verbose_vm;
323 print('Running $name [$testIndex/$totalTests]'); 323 print('Running $name [$testIndex/$totalTests]');
324 testIndex++; 324 testIndex++;
325 await test(isolate); 325 await test(isolate);
326 } 326 }
327 } 327 }
328 328
329 print('All service tests completed successfully.'); 329 print('All service tests completed successfully.');
330 testsDone = true; 330 testsDone = true;
331 await process.requestExit(); 331 await process.requestExit();
332 }, onError: (error, stackTrace) { 332 }, onError: (error, stackTrace) {
333 if (testsDone) { 333 if (testsDone) {
334 print('Ignoring late exception during process exit:\n' 334 print('Ignoring late exception during process exit:\n'
335 '$error\n#stackTrace'); 335 '$error\n#stackTrace');
336 } else { 336 } else {
337 process.requestExit(); 337 process.requestExit();
338 print('Unexpected exception in service tests: $error\n$stackTrace'); 338 print('Unexpected exception in service tests: $error\n$stackTrace');
339 throw error; 339 throw error;
340 } 340 }
341 }); 341 });
342 }); 342 });
343 } 343 }
344
345
346
347 // This is a copy-in of https://codereview.chromium.org/2670303003/
348 // --- hopefully either that will be accepted, or we'll find some other soluti on
349 Future<Isolate> getIsolate(WebSocketVM vm) async {
350 if (vm.isolates.isNotEmpty) {
351 var isolate = await vm.isolates.first.load();
352 if (isolate is Isolate) {
353 return isolate;
354 }
355 }
356
357 Completer completer = new Completer();
358 vm.getEventStream(VM.kIsolateStream).then((stream) {
359 var subscription;
360 subscription = stream.listen((ServiceEvent event) async {
361 if (completer == null) {
362 subscription.cancel();
363 return;
364 }
365 if (event.kind == ServiceEvent.kIsolateRunnable) {
366 if (vm.isolates.isNotEmpty) {
367 vm.isolates.first.load().then((result) {
368 if (result is Isolate) {
369 subscription.cancel();
370 completer.complete(result);
371 completer = null;
372 }
373 });
374 }
375 }
376 });
377 });
378
379 // The isolate may have started before we subscribed.
380 if (vm.isolates.isNotEmpty) {
381 vm.isolates.first.reload().then((result) async {
382 if (completer != null && result is Isolate) {
383 completer.complete(result);
384 completer = null;
385 }
386 });
387 }
388 return await completer.future;
389 }
344 } 390 }
345 391
346 /// Runs [tests] in sequence, each of which should take an [Isolate] and 392 /// Runs [tests] in sequence, each of which should take an [Isolate] and
347 /// return a [Future]. Code for setting up state can run before and/or 393 /// return a [Future]. Code for setting up state can run before and/or
348 /// concurrently with the tests. Uses [mainArgs] to determine whether 394 /// concurrently with the tests. Uses [mainArgs] to determine whether
349 /// to run tests or testee in this invokation of the script. 395 /// to run tests or testee in this invokation of the script.
350 Future runIsolateTests(List<String> mainArgs, 396 Future runIsolateTests(List<String> mainArgs,
351 List<IsolateTest> tests, 397 List<IsolateTest> tests,
352 {testeeBefore(), 398 {testeeBefore(),
353 testeeConcurrent(), 399 testeeConcurrent(),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 new _ServiceTesterRunner().run( 483 new _ServiceTesterRunner().run(
438 mainArgs: mainArgs, 484 mainArgs: mainArgs,
439 extraArgs: extraArgs, 485 extraArgs: extraArgs,
440 vmTests: tests, 486 vmTests: tests,
441 pause_on_start: pause_on_start, 487 pause_on_start: pause_on_start,
442 pause_on_exit: pause_on_exit, 488 pause_on_exit: pause_on_exit,
443 verbose_vm: verbose_vm, 489 verbose_vm: verbose_vm,
444 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); 490 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions);
445 } 491 }
446 } 492 }
493
494 /// Whether we're running from kernel.
495 bool isKernel(Isolate isolate) {
496 return isolate.name.contains(r".dill$");
497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698