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

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

Issue 1217823009: Make VM event streams look like real dart streams. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Polish Created 5 years, 5 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:isolate' as I; 7 import 'dart:isolate' as I;
8 8
9 import 'package:observatory/service_io.dart'; 9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 running++; 47 running++;
48 } 48 }
49 } 49 }
50 return running; 50 return running;
51 } 51 }
52 52
53 var tests = [ 53 var tests = [
54 (VM vm) async { 54 (VM vm) async {
55 // Wait for the testee to start all of the isolates. 55 // Wait for the testee to start all of the isolates.
56 if (vm.isolates.length != spawnCount + 1) { 56 if (vm.isolates.length != spawnCount + 1) {
57 await processServiceEvents(vm, (event, sub, completer) { 57 await processIsolateEvents(vm, (event, sub, completer) {
58 if (event.kind == ServiceEvent.kIsolateStart) { 58 if (event.kind == ServiceEvent.kIsolateStart) {
59 if (vm.isolates.length == spawnCount + 1) { 59 if (vm.isolates.length == spawnCount + 1) {
60 sub.cancel(); 60 sub.cancel();
61 completer.complete(null); 61 completer.complete(null);
62 } 62 }
63 } 63 }
64 }); 64 });
65 } 65 }
66 expect(vm.isolates.length, spawnCount + 1); 66 expect(vm.isolates.length, spawnCount + 1);
67 }, 67 },
68 68
69 (VM vm) async { 69 (VM vm) async {
70 // Load each isolate. 70 // Load each isolate.
71 for (var isolate in vm.isolates) { 71 for (var isolate in vm.isolates) {
72 await isolate.load(); 72 await isolate.load();
73 } 73 }
74 }, 74 },
75 75
76 (VM vm) async { 76 (VM vm) async {
77 // Wait for all spawned isolates to hit pause-at-exit. 77 // Wait for all spawned isolates to hit pause-at-exit.
78 if (numPaused(vm) != spawnCount) { 78 if (numPaused(vm) != spawnCount) {
79 await processServiceEvents(vm, (event, sub, completer) { 79 await processDebugEvents(vm, (event, sub, completer) {
80 if (event.kind == ServiceEvent.kPauseExit) { 80 if (event.kind == ServiceEvent.kPauseExit) {
81 if (numPaused(vm) == spawnCount) { 81 if (numPaused(vm) == spawnCount) {
82 sub.cancel(); 82 sub.cancel();
83 completer.complete(null); 83 completer.complete(null);
84 } 84 }
85 } 85 }
86 }); 86 });
87 } 87 }
88 expect(numPaused(vm), spawnCount); 88 expect(numPaused(vm), spawnCount);
89 expect(numRunning(vm), 1); 89 expect(numRunning(vm), 1);
90 }, 90 },
91 91
92 92
93 (VM vm) async { 93 (VM vm) async {
94 var resumedReceived = 0; 94 var resumedReceived = 0;
95 var eventsDone = processServiceEvents(vm, (event, sub, completer) { 95 var eventsDone = processIsolateEvents(vm, (event, sub, completer) {
96 if (event.kind == ServiceEvent.kIsolateExit) { 96 if (event.kind == ServiceEvent.kIsolateExit) {
97 resumedReceived++; 97 resumedReceived++;
98 if (resumedReceived == resumeCount) { 98 if (resumedReceived == resumeCount) {
99 sub.cancel(); 99 sub.cancel();
100 completer.complete(null); 100 completer.complete(null);
101 } 101 }
102 } 102 }
103 }); 103 });
104 var resumesIssued = 0; 104 var resumesIssued = 0;
105 var isolateList = vm.isolates.toList(); 105 var isolateList = vm.isolates.toList();
(...skipping 15 matching lines...) Expand all
121 (VM vm) async { 121 (VM vm) async {
122 expect(numPaused(vm), spawnCount - resumeCount); 122 expect(numPaused(vm), spawnCount - resumeCount);
123 expect(numRunning(vm), 1); 123 expect(numRunning(vm), 1);
124 }, 124 },
125 ]; 125 ];
126 126
127 main(args) async => runVMTests(args, tests, 127 main(args) async => runVMTests(args, tests,
128 testeeBefore: before, 128 testeeBefore: before,
129 testeeConcurrent: during, 129 testeeConcurrent: during,
130 pause_on_exit: true); 130 pause_on_exit: true);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698