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 // VMOptions=--trace_shutdown | 4 // VMOptions=--trace_shutdown |
5 import 'dart:io'; | 5 import 'dart:io'; |
6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
7 | 7 |
8 final SPAWN_PACKAGE_CONFIG = "foobar:///no/such/file/"; | 8 final SPAWN_PACKAGE_CONFIG = "foobar:///no/such/file/"; |
9 | 9 |
10 main([args, port]) async { | 10 main([args, port]) async { |
11 if (port != null) { | 11 if (port != null) { |
12 testPackageConfig(port); | 12 testPackageConfig(port); |
13 return; | 13 return; |
14 } | 14 } |
15 var p = new RawReceivePort(); | 15 var p = new RawReceivePort(); |
16 Isolate.spawnUri(Platform.script, | 16 Isolate.spawnUri(Platform.script, [], p.sendPort, |
17 [], | 17 packageConfig: Uri.parse(SPAWN_PACKAGE_CONFIG)); |
18 p.sendPort, | |
19 packageConfig: Uri.parse(SPAWN_PACKAGE_CONFIG)); | |
20 p.handler = (msg) { | 18 p.handler = (msg) { |
21 p.close(); | 19 p.close(); |
22 if (msg[0] != SPAWN_PACKAGE_CONFIG) { | 20 if (msg[0] != SPAWN_PACKAGE_CONFIG) { |
23 throw "Bad package config in child isolate: ${msg[0]}"; | 21 throw "Bad package config in child isolate: ${msg[0]}"; |
24 } | 22 } |
25 if (msg[1] != null) { | 23 if (msg[1] != null) { |
26 throw "Non-null loaded package config in isolate: ${msg[1]}"; | 24 throw "Non-null loaded package config in isolate: ${msg[1]}"; |
27 } | 25 } |
28 print("SUCCESS"); | 26 print("SUCCESS"); |
29 }; | 27 }; |
30 print("Spawning isolate's package config: ${await Isolate.packageConfig}"); | 28 print("Spawning isolate's package config: ${await Isolate.packageConfig}"); |
31 } | 29 } |
32 | 30 |
33 testPackageConfig(port) async { | 31 testPackageConfig(port) async { |
34 var packageConfigStr = Platform.packageConfig; | 32 var packageConfigStr = Platform.packageConfig; |
35 var packageConfig = await Isolate.packageConfig; | 33 var packageConfig = await Isolate.packageConfig; |
36 print("Spawned isolate's package config flag: $packageConfigStr"); | 34 print("Spawned isolate's package config flag: $packageConfigStr"); |
37 print("Spawned isolate's loaded package config: $packageConfig"); | 35 print("Spawned isolate's loaded package config: $packageConfig"); |
38 port.send([packageConfigStr, packageConfig?.toString()]); | 36 port.send([packageConfigStr, packageConfig?.toString()]); |
39 } | 37 } |
OLD | NEW |