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

Unified Diff: tests/isolate/package_map_test.dart

Issue 1403693002: - Implement package map parameter when spawning isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/package_map_test.dart
diff --git a/tests/isolate/package_map_test.dart b/tests/isolate/package_map_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2f0f3e0edd7aa269b5d113430808efd8ef2e7e1a
--- /dev/null
+++ b/tests/isolate/package_map_test.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2015, 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.
+
+import 'dart:io';
+import 'dart:isolate';
+
+final NOT_HERE = "notHere";
+final NOT_HERE_URI = "file:///no/such/file/";
+
+class Foo {}
+
+void main([args, port]) {
+ if (port != null) {
+ testPackageRoot(port);
+ return;
+ }
+ var p = new RawReceivePort();
+ p.handler = (msg) {
+ p.close();
+ // Cannot use the expect package here because the spawned isolate
+ // would not be able to handle it.
+ if (msg is! List) {
+ throw "Bad response from child isolate: $msg";
+ }
+ if (msg.length != 2) {
+ throw "Length should be 2: ${msg.length}\nmsg: $msg";
+ }
+ if (msg[0] != NOT_HERE) {
+ throw "Key should be $NOT_HERE: ${msg[0]}";
+ }
+ if (msg[1] != NOT_HERE_URI) {
+ throw "Value should be $NOT_HERE_URI: ${msg[1]}";
+ }
+ };
+ Isolate.spawnUri(Platform.script,
+ [],
+ p.sendPort,
+ packages: {
+ NOT_HERE: Uri.parse(NOT_HERE_URI)
+ });
+}
+
+testPackageRoot(port) async {
+ var packageMap = await Isolate.packageMap;
+ var packageMapEntries = [];
+ if (packageMap is! Map) {
+ port.send("packageMap is not a Map: ${packageMap.runtimeType}");
+ return;
+ }
+ var ok = true;
+ packageMap.forEach((k, v) {
+ if (ok && (k is! String)) {
+ port.send("Key $k is not a String: ${k.runtimeType}");
+ ok = false;
+ }
+ packageMapEntries.add(k);
+ if (ok && (v is! Uri)) {
+ port.send("Value $v is not a Uri: ${v.runtimeType}");
+ ok = false;
+ }
+ packageMapEntries.add(v.toString());
+ });
+ if (ok) {
+ port.send(packageMapEntries);
+ }
+}
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698