OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:io'; |
| 6 import 'dart:isolate'; |
| 7 |
| 8 final PACKAGE_URI = "package:foo/bar.dart"; |
| 9 final PACKAGE_PATH = "file:///no/such/directory/bar.dart"; |
| 10 |
| 11 void main([args, port]) async { |
| 12 if (port != null) { |
| 13 testPackageResolution(port); |
| 14 return; |
| 15 } |
| 16 var p = new RawReceivePort(); |
| 17 Isolate.spawnUri(Platform.script, |
| 18 [], |
| 19 p.sendPort, |
| 20 automaticPackageResolution: true); |
| 21 p.handler = (msg) { |
| 22 p.close(); |
| 23 if (msg is! List) { |
| 24 print(msg.runtimeType); |
| 25 throw "Failure return from spawned isolate:\n\n$msg"; |
| 26 } |
| 27 var child_pkg_config = Platform.script.resolve(".packages"); |
| 28 if (msg[0] != child_pkg_config.toString()) { |
| 29 throw "Bad package config in child isolate: ${msg[0]}\n" |
| 30 "Expected: $child_pkg_config"; |
| 31 } |
| 32 if (msg[1] != PACKAGE_PATH) { |
| 33 throw "Package path not matching: ${msg[1]}"; |
| 34 } |
| 35 print("SUCCESS"); |
| 36 }; |
| 37 print("Spawning isolate's package root: ${await Isolate.packageRoot}"); |
| 38 } |
| 39 |
| 40 testPackageResolution(port) async { |
| 41 try { |
| 42 var packageRootStr = Platform.packageRoot; |
| 43 var packageConfigStr = Platform.packageConfig; |
| 44 var packageConfig = await Isolate.packageConfig; |
| 45 var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI)); |
| 46 print("Spawned isolate's package root flag: $packageRootStr"); |
| 47 print("Spawned isolate's package config flag: $packageConfigStr"); |
| 48 print("Spawned isolate's loaded package config: $packageConfig"); |
| 49 print("Spawned isolate's resolved package path: $resolvedPkg"); |
| 50 port.send([packageConfig?.toString(), resolvedPkg?.toString()]); |
| 51 } catch (e, s) { |
| 52 port.send("$e\n$s\n"); |
| 53 } |
| 54 } |
OLD | NEW |