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

Side by Side Diff: tests/isolate/issue_21398_parent_isolate1_test.dart

Issue 1477043002: Fix tests that don't catch asynchronous errors from isolate spawning. Update co19 status. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « tests/co19/co19-dartium.status ('k') | tests/isolate/issue_21398_parent_isolate2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 // Note: the following comment is used by test.dart to additionally compile the 5 // Note: the following comment is used by test.dart to additionally compile the
6 // other isolate's code. 6 // other isolate's code.
7 // OtherScripts=issue_21398_child_isolate1.dart 7 // OtherScripts=issue_21398_child_isolate1.dart
8 // OtherScripts=issue_21398_child_isolate11.dart 8 // OtherScripts=issue_21398_child_isolate11.dart
9 9
10 import 'dart:isolate'; 10 import 'dart:isolate';
11 import 'dart:async'; 11 import 'dart:async';
12 import "package:expect/expect.dart"; 12 import "package:expect/expect.dart";
13 import 'package:async_helper/async_helper.dart';
13 14
14 class FromMainIsolate { 15 class FromMainIsolate {
15 String toString() => 'from main isolate'; 16 String toString() => 'from main isolate';
16 int get fld => 10; 17 int get fld => 10;
17 } 18 }
18 19
19 func1Child(args) { 20 func1Child(args) {
20 var receivePort = new ReceivePort(); 21 var receivePort = new ReceivePort();
21 var sendPort = args[0]; 22 var sendPort = args[0];
22 sendPort.send(receivePort.sendPort); 23 sendPort.send(receivePort.sendPort);
23 receivePort.listen( 24 receivePort.listen(
24 (msg) { 25 (msg) {
25 Expect.isTrue(msg is FromMainIsolate); 26 Expect.isTrue(msg is FromMainIsolate);
26 Expect.equals(10, msg.fld); 27 Expect.equals(10, msg.fld);
27 receivePort.close(); 28 receivePort.close();
29 sendPort.send("done");
28 }, 30 },
29 onError: (e) => print('$e') 31 onError: (e) => print('$e')
30 ); 32 );
31 } 33 }
32 34
33 35
34 func2Child(args) { 36 func2Child(args) {
35 var receivePort = new ReceivePort(); 37 var receivePort = new ReceivePort();
36 var sendPort = args[0]; 38 var sendPort = args[0];
37 sendPort.send(receivePort.sendPort); 39 sendPort.send(receivePort.sendPort);
(...skipping 12 matching lines...) Expand all
50 var receive1 = new ReceivePort(); 52 var receive1 = new ReceivePort();
51 var receive2 = new ReceivePort(); 53 var receive2 = new ReceivePort();
52 54
53 var spawnFunctionIsolate1SendPort; 55 var spawnFunctionIsolate1SendPort;
54 var spawnFunctionIsolate2SendPort; 56 var spawnFunctionIsolate2SendPort;
55 57
56 // First spawn the first isolate using spawnFunction, this isolate will 58 // First spawn the first isolate using spawnFunction, this isolate will
57 // create a receivePort and send it's sendPort back and then it will just 59 // create a receivePort and send it's sendPort back and then it will just
58 // sit there listening for a message from the second isolate spawned 60 // sit there listening for a message from the second isolate spawned
59 // using spawnFunction. 61 // using spawnFunction.
60 Isolate.spawn(func1Child, [receive1.sendPort]).then( 62 asyncStart();
63 return Isolate.spawn(func1Child, [receive1.sendPort]).then(
61 (isolate) { 64 (isolate) {
62 receive1.listen( 65 receive1.listen(
63 (msg) { 66 (msg) {
64 Expect.isTrue(msg is SendPort); 67 if (msg is SendPort) {
65 spawnFunctionIsolate1SendPort = msg; 68 spawnFunctionIsolate1SendPort = msg;
66 receive1.close();
67 69
68 // Now spawn the second isolate using spawnFunction, this isolate 70 // Now spawn the second isolate using spawnFunction, this isolate
69 // will create a receivePort and send it's sendPort back and then 71 // will create a receivePort and send it's sendPort back and then
70 // wait for the third isolate spawned using spawnUri to send it 72 // wait for the third isolate spawned using spawnUri to send it
71 // a sendPort to which it will try and send a non "literal-like" 73 // a sendPort to which it will try and send a non "literal-like"
72 // object. 74 // object.
73 Isolate.spawn(func2Child, [receive2.sendPort]).then( 75 Isolate.spawn(func2Child, [receive2.sendPort]).then(
74 (isolate) { 76 (isolate) {
75 receive2.listen( 77 receive2.listen(
76 (msg) { 78 (msg) {
77 spawnFunctionIsolate2SendPort = msg; 79 spawnFunctionIsolate2SendPort = msg;
78 receive2.close(); 80 receive2.close();
79 81
80 // Now spawn an isolate using spawnUri and send these send 82 // Now spawn an isolate using spawnUri and send these send
81 // ports over to it. This isolate will send one of the 83 // ports over to it. This isolate will send one of the
82 // sendports over to the other. 84 // sendports over to the other.
83 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate1.dart'), 85 Isolate
84 [spawnFunctionIsolate1SendPort, 86 .spawnUri(Uri.parse('issue_21398_child_isolate1.dart'),
85 spawnFunctionIsolate2SendPort], "no-msg"); 87 [spawnFunctionIsolate1SendPort,
86 }, 88 spawnFunctionIsolate2SendPort], "no-msg") ;
87 onError: (e) => print('$e') 89 },
88 ); 90 onError: (e) => print('$e')
89 } 91 );
90 ); 92 }
93 );
94 } else if (msg == "done") {
95 receive1.close();
96 asyncEnd();
97 } else {
98 Expect.fail("Invalid message received: $msg");
99 }
91 }, 100 },
92 onError: (e) => print('$e') 101 onError: (e) => print('$e')
93 ); 102 );
94 } 103 }
95 ); 104 );
96 } 105 }
97 106
98 107
99 uriChild(args) { 108 uriChild(args) {
100 var receivePort = new ReceivePort(); 109 var receivePort = new ReceivePort();
101 var sendPort = args[0]; 110 var sendPort = args[0];
102 sendPort.send(receivePort.sendPort); 111 sendPort.send(receivePort.sendPort);
103 receivePort.listen( 112 receivePort.listen(
104 (msg) { 113 (msg) {
105 Expect.isTrue(msg is String); 114 Expect.isTrue(msg is String);
106 Expect.equals("Invalid Argument(s).", msg); 115 Expect.equals("Invalid Argument(s).", msg);
107 receivePort.close(); 116 receivePort.close();
117 sendPort.send("done");
108 }, 118 },
109 onError: (e) => print('$e') 119 onError: (e) => print('$e')
110 ); 120 );
111 } 121 }
112 122
113 123
114 spawnUriTest() { 124 spawnUriTest() {
115 var receive1 = new ReceivePort(); 125 var receive1 = new ReceivePort();
116 var receive2 = new ReceivePort(); 126 var receive2 = new ReceivePort();
117 127
118 var spawnFunctionIsolateSendPort; 128 var spawnFunctionIsolateSendPort;
119 var spawnUriIsolateSendPort; 129 var spawnUriIsolateSendPort;
120 130
121 // First spawn the first isolate using spawnFunction, this isolate will 131 // First spawn the first isolate using spawnFunction, this isolate will
122 // create a receivePort and send it's sendPort back and then it will just 132 // create a receivePort and send it's sendPort back and then it will just
123 // sit there listening for a message from the second isolate spawned 133 // sit there listening for a message from the second isolate spawned
124 // using spawnFunction. 134 // using spawnFunction.
135 asyncStart();
125 Isolate.spawn(uriChild, [receive1.sendPort]).then( 136 Isolate.spawn(uriChild, [receive1.sendPort]).then(
126 (isolate) { 137 (isolate) {
127 receive1.listen( 138 receive1.listen(
128 (msg) { 139 (msg) {
129 Expect.isTrue(msg is SendPort); 140 if (msg is SendPort) {
130 spawnFunctionIsolateSendPort = msg; 141 spawnFunctionIsolateSendPort = msg;
131 receive1.close();
132 142
133 // Now spawn the second isolate using spawnUri, this isolate 143 // Now spawn the second isolate using spawnUri, this isolate
134 // will create a receivePort and send it's sendPort back and then 144 // will create a receivePort and send it's sendPort back and then
135 // wait for the third isolate spawned using spawnUri to send it 145 // wait for the third isolate spawned using spawnUri to send it
136 // a sendPort to which it will try and send a non "literal-like" 146 // a sendPort to which it will try and send a non "literal-like"
137 // object. 147 // object.
138 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate11.dart'), 148 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate11.dart'),
139 [], 149 [],
140 receive2.sendPort).then( 150 receive2.sendPort).then(
141 (isolate) { 151 (isolate) {
142 receive2.listen( 152 receive2.listen(
143 (msg) { 153 (msg) {
144 spawnUriIsolateSendPort = msg; 154 spawnUriIsolateSendPort = msg;
145 receive2.close(); 155 receive2.close();
146 156
147 // Now spawn an isolate using spawnUri and send these send 157 // Now spawn an isolate using spawnUri and send these send
148 // ports over to it. This isolate will send one of the 158 // ports over to it. This isolate will send one of the
149 // sendports over to the other. 159 // sendports over to the other.
150 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate1.dart'), 160 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate1.dart'),
151 [spawnFunctionIsolateSendPort, 161 [spawnFunctionIsolateSendPort,
152 spawnUriIsolateSendPort], "no-msg"); 162 spawnUriIsolateSendPort], "no-msg");
153 }, 163 },
154 onError: (e) => print('$e') 164 onError: (e) => print('$e')
155 ); 165 );
156 } 166 }
157 ); 167 );
168 } else if (msg == "done") {
169 receive1.close();
170 asyncEnd();
171 } else {
172 Expect.fail("Invalid message received: $msg");
173 }
158 }, 174 },
159 onError: (e) => print('$e') 175 onError: (e) => print('$e')
160 ); 176 );
161 } 177 }
162 ); 178 );
163 } 179 }
164 180
165 181
166 main() { 182 main() {
167 spawnFuncTest(); 183 spawnFuncTest();
168 spawnUriTest(); 184 spawnUriTest();
169 } 185 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dartium.status ('k') | tests/isolate/issue_21398_parent_isolate2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698