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

Unified 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, 1 month 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/issue_21398_parent_isolate1_test.dart
diff --git a/tests/isolate/issue_21398_parent_isolate1_test.dart b/tests/isolate/issue_21398_parent_isolate1_test.dart
index 1c3aeb88b88397ffd87589123cc7fd6c0027c383..6f036bd771abfb3d8e0fe84cc1490a60f0c16c1c 100644
--- a/tests/isolate/issue_21398_parent_isolate1_test.dart
+++ b/tests/isolate/issue_21398_parent_isolate1_test.dart
@@ -10,6 +10,7 @@
import 'dart:isolate';
import 'dart:async';
import "package:expect/expect.dart";
+import 'package:async_helper/async_helper.dart';
class FromMainIsolate {
String toString() => 'from main isolate';
@@ -25,6 +26,7 @@ func1Child(args) {
Expect.isTrue(msg is FromMainIsolate);
Expect.equals(10, msg.fld);
receivePort.close();
+ sendPort.send("done");
},
onError: (e) => print('$e')
);
@@ -57,37 +59,44 @@ spawnFuncTest() {
// create a receivePort and send it's sendPort back and then it will just
// sit there listening for a message from the second isolate spawned
// using spawnFunction.
- Isolate.spawn(func1Child, [receive1.sendPort]).then(
+ asyncStart();
+ return Isolate.spawn(func1Child, [receive1.sendPort]).then(
(isolate) {
receive1.listen(
(msg) {
- Expect.isTrue(msg is SendPort);
- spawnFunctionIsolate1SendPort = msg;
- receive1.close();
-
- // Now spawn the second isolate using spawnFunction, this isolate
- // will create a receivePort and send it's sendPort back and then
- // wait for the third isolate spawned using spawnUri to send it
- // a sendPort to which it will try and send a non "literal-like"
- // object.
- Isolate.spawn(func2Child, [receive2.sendPort]).then(
- (isolate) {
- receive2.listen(
- (msg) {
- spawnFunctionIsolate2SendPort = msg;
- receive2.close();
-
- // Now spawn an isolate using spawnUri and send these send
- // ports over to it. This isolate will send one of the
- // sendports over to the other.
- Isolate.spawnUri(Uri.parse('issue_21398_child_isolate1.dart'),
- [spawnFunctionIsolate1SendPort,
- spawnFunctionIsolate2SendPort], "no-msg");
- },
- onError: (e) => print('$e')
- );
- }
- );
+ if (msg is SendPort) {
+ spawnFunctionIsolate1SendPort = msg;
+
+ // Now spawn the second isolate using spawnFunction, this isolate
+ // will create a receivePort and send it's sendPort back and then
+ // wait for the third isolate spawned using spawnUri to send it
+ // a sendPort to which it will try and send a non "literal-like"
+ // object.
+ Isolate.spawn(func2Child, [receive2.sendPort]).then(
+ (isolate) {
+ receive2.listen(
+ (msg) {
+ spawnFunctionIsolate2SendPort = msg;
+ receive2.close();
+
+ // Now spawn an isolate using spawnUri and send these send
+ // ports over to it. This isolate will send one of the
+ // sendports over to the other.
+ Isolate
+ .spawnUri(Uri.parse('issue_21398_child_isolate1.dart'),
+ [spawnFunctionIsolate1SendPort,
+ spawnFunctionIsolate2SendPort], "no-msg");
+ },
+ onError: (e) => print('$e')
+ );
+ }
+ );
+ } else if (msg == "done") {
+ receive1.close();
+ asyncEnd();
+ } else {
+ Expect.fail("Invalid message received: $msg");
+ }
},
onError: (e) => print('$e')
);
@@ -105,6 +114,7 @@ uriChild(args) {
Expect.isTrue(msg is String);
Expect.equals("Invalid Argument(s).", msg);
receivePort.close();
+ sendPort.send("done");
},
onError: (e) => print('$e')
);
@@ -122,13 +132,13 @@ spawnUriTest() {
// create a receivePort and send it's sendPort back and then it will just
// sit there listening for a message from the second isolate spawned
// using spawnFunction.
+ asyncStart();
Isolate.spawn(uriChild, [receive1.sendPort]).then(
(isolate) {
receive1.listen(
(msg) {
- Expect.isTrue(msg is SendPort);
- spawnFunctionIsolateSendPort = msg;
- receive1.close();
+ if (msg is SendPort) {
+ spawnFunctionIsolateSendPort = msg;
// Now spawn the second isolate using spawnUri, this isolate
// will create a receivePort and send it's sendPort back and then
@@ -149,12 +159,18 @@ spawnUriTest() {
// sendports over to the other.
Isolate.spawnUri(Uri.parse('issue_21398_child_isolate1.dart'),
[spawnFunctionIsolateSendPort,
- spawnUriIsolateSendPort], "no-msg");
+ spawnUriIsolateSendPort], "no-msg");
},
onError: (e) => print('$e')
);
}
);
+ } else if (msg == "done") {
+ receive1.close();
+ asyncEnd();
+ } else {
+ Expect.fail("Invalid message received: $msg");
+ }
},
onError: (e) => print('$e')
);
« 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