| 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 SPAWN_PACKAGE_ROOT = "file:///no/such/package/root/"; |   8 final SPAWN_PACKAGE_ROOT = "file:///no/such/package/root/"; | 
|   9 final PACKAGE_URI = "package:foo/bar.dart"; |   9 final PACKAGE_URI = "package:foo/bar.dart"; | 
|  10 final PACKAGE_PATH = "file:///no/such/package/root/foo/bar.dart"; |  10 final PACKAGE_PATH = "file:///no/such/package/root/foo/bar.dart"; | 
|  11  |  11  | 
|  12 main([args, port]) async { |  12 main([args, port]) async { | 
|  13   if (port != null) { |  13   if (port != null) { | 
|  14     testPackageResolution(port); |  14     testPackageResolution(port); | 
|  15     return; |  15     return; | 
|  16   } |  16   } | 
|  17   var p = new RawReceivePort(); |  17   var p = new RawReceivePort(); | 
|  18   Isolate.spawnUri(Platform.script, |  18   Isolate.spawnUri(Platform.script, [], p.sendPort, | 
|  19                    [], |  19       packageRoot: Uri.parse(SPAWN_PACKAGE_ROOT)); | 
|  20                    p.sendPort, |  | 
|  21                    packageRoot: Uri.parse(SPAWN_PACKAGE_ROOT)); |  | 
|  22   p.handler = (msg) { |  20   p.handler = (msg) { | 
|  23     p.close(); |  21     p.close(); | 
|  24     if (msg is! List) { |  22     if (msg is! List) { | 
|  25       print(msg.runtimeType); |  23       print(msg.runtimeType); | 
|  26       throw "Failure return from spawned isolate:\n\n$msg"; |  24       throw "Failure return from spawned isolate:\n\n$msg"; | 
|  27     } |  25     } | 
|  28     if (msg[0] != SPAWN_PACKAGE_ROOT) { |  26     if (msg[0] != SPAWN_PACKAGE_ROOT) { | 
|  29       throw "Bad package root in child isolate: ${msg[0]}"; |  27       throw "Bad package root in child isolate: ${msg[0]}"; | 
|  30     } |  28     } | 
|  31     if (msg[1] != PACKAGE_PATH) { |  29     if (msg[1] != PACKAGE_PATH) { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  42     var packageRoot = await Isolate.packageRoot; |  40     var packageRoot = await Isolate.packageRoot; | 
|  43     var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI)); |  41     var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI)); | 
|  44     print("Spawned isolate's package root flag: $packageRootStr"); |  42     print("Spawned isolate's package root flag: $packageRootStr"); | 
|  45     print("Spawned isolate's loaded package root: $packageRoot"); |  43     print("Spawned isolate's loaded package root: $packageRoot"); | 
|  46     print("Spawned isolate's resolved package path: $resolvedPkg"); |  44     print("Spawned isolate's resolved package path: $resolvedPkg"); | 
|  47     port.send([packageRoot?.toString(), resolvedPkg?.toString()]); |  45     port.send([packageRoot?.toString(), resolvedPkg?.toString()]); | 
|  48   } catch (e, s) { |  46   } catch (e, s) { | 
|  49     port.send("$e\n$s\n"); |  47     port.send("$e\n$s\n"); | 
|  50   } |  48   } | 
|  51 } |  49 } | 
| OLD | NEW |