OLD | NEW |
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 import 'dart:io'; | 5 import 'dart:io'; |
6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
7 | 7 |
8 final NOT_HERE = "notHere"; | 8 final NOT_HERE = "notHere"; |
9 final NOT_HERE_URI = "file:///no/such/file/"; | 9 final NOT_HERE_URI = "file:///no/such/file/"; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 if (msg[0] != NOT_HERE) { | 29 if (msg[0] != NOT_HERE) { |
30 throw "Key should be $NOT_HERE: ${msg[0]}"; | 30 throw "Key should be $NOT_HERE: ${msg[0]}"; |
31 } | 31 } |
32 if (msg[1] != NOT_HERE_URI) { | 32 if (msg[1] != NOT_HERE_URI) { |
33 throw "Value should be $NOT_HERE_URI: ${msg[1]}"; | 33 throw "Value should be $NOT_HERE_URI: ${msg[1]}"; |
34 } | 34 } |
35 }; | 35 }; |
36 Isolate.spawnUri(Platform.script, | 36 Isolate.spawnUri(Platform.script, |
37 [], | 37 [], |
38 p.sendPort, | 38 p.sendPort, |
39 packages: { | 39 packageMap: { |
40 NOT_HERE: Uri.parse(NOT_HERE_URI) | 40 NOT_HERE: Uri.parse(NOT_HERE_URI) |
41 }); | 41 }); |
42 } | 42 } |
43 | 43 |
44 testPackageRoot(port) async { | 44 testPackageRoot(port) async { |
45 var packageMap = await Isolate.packageMap; | 45 var packageMap = await Isolate.packageMap; |
46 var packageMapEntries = []; | 46 var packageMapEntries = []; |
47 if (packageMap is! Map) { | 47 if (packageMap is! Map) { |
48 port.send("packageMap is not a Map: ${packageMap.runtimeType}"); | 48 port.send("packageMap is not a Map: ${packageMap.runtimeType}"); |
49 return; | 49 return; |
50 } | 50 } |
51 var ok = true; | 51 var ok = true; |
52 packageMap.forEach((k, v) { | 52 packageMap.forEach((k, v) { |
53 if (ok && (k is! String)) { | 53 if (ok && (k is! String)) { |
54 port.send("Key $k is not a String: ${k.runtimeType}"); | 54 port.send("Key $k is not a String: ${k.runtimeType}"); |
55 ok = false; | 55 ok = false; |
56 } | 56 } |
57 packageMapEntries.add(k); | 57 packageMapEntries.add(k); |
58 if (ok && (v is! Uri)) { | 58 if (ok && (v is! Uri)) { |
59 port.send("Value $v is not a Uri: ${v.runtimeType}"); | 59 port.send("Value $v is not a Uri: ${v.runtimeType}"); |
60 ok = false; | 60 ok = false; |
61 } | 61 } |
62 packageMapEntries.add(v.toString()); | 62 packageMapEntries.add(v.toString()); |
63 }); | 63 }); |
64 if (ok) { | 64 if (ok) { |
65 port.send(packageMapEntries); | 65 port.send(packageMapEntries); |
66 } | 66 } |
67 } | 67 } |
OLD | NEW |