6b3abe0a98
Issue b/177800357. TEST=existing test suite Change-Id: Id6b113932ab7014b8fa6c105845c5c490b60f5e8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181320 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
78 lines
2.0 KiB
Dart
78 lines
2.0 KiB
Dart
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// VMOptions=--enable-isolate-groups --experimental-enable-isolate-groups-jit
|
|
// VMOptions=--no-enable-isolate-groups
|
|
|
|
// Testing that Isolate.spawn copies the source code of the parent isolate,
|
|
// rather than rereading the parent's source URI.
|
|
// https://github.com/dart-lang/sdk/issues/6610
|
|
|
|
// Isolate structure:
|
|
// Root 1 -> Branch 1 -> Leaf 1
|
|
// /
|
|
// main
|
|
// \
|
|
// Root 2 -> Branch 2 -> Leaf 2
|
|
|
|
library spawn_tests;
|
|
|
|
import "dart:io";
|
|
import 'dart:isolate';
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
HttpServer.bind("127.0.0.1", 0).then((server) {
|
|
var count = 0;
|
|
server.listen((HttpRequest request) {
|
|
++count;
|
|
request.response.write("""
|
|
import 'dart:isolate';
|
|
|
|
void main(_, SendPort port) {
|
|
root(port);
|
|
}
|
|
|
|
void root(SendPort port) {
|
|
port.send("Root ${count}");
|
|
Isolate.spawn(branch, port);
|
|
}
|
|
|
|
void branch(SendPort port) {
|
|
port.send("Branch ${count}");
|
|
Isolate.spawn(leaf, port);
|
|
}
|
|
|
|
void leaf(SendPort port) {
|
|
port.send("Leaf ${count}");
|
|
}
|
|
""");
|
|
request.response.close();
|
|
});
|
|
|
|
ReceivePort port = new ReceivePort();
|
|
var messageSet = Set();
|
|
port.listen((message) {
|
|
messageSet.add(message);
|
|
if (messageSet.length >= 6) {
|
|
server.close();
|
|
port.close();
|
|
Expect.setEquals([
|
|
"Root 1",
|
|
"Root 2",
|
|
"Branch 1",
|
|
"Branch 2",
|
|
"Leaf 1",
|
|
"Leaf 2",
|
|
], messageSet);
|
|
}
|
|
});
|
|
|
|
Isolate.spawnUri(
|
|
Uri.parse("http://127.0.0.1:${server.port}"), [], port.sendPort);
|
|
Isolate.spawnUri(
|
|
Uri.parse("http://127.0.0.1:${server.port}"), [], port.sendPort);
|
|
});
|
|
}
|