| 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 library test.util.io; | 5 library test.util.io; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 /// [LoadException] is thrown. | 93 /// [LoadException] is thrown. |
| 94 String packageRootFor(String path, [String override]) { | 94 String packageRootFor(String path, [String override]) { |
| 95 var packageRoot = override == null | 95 var packageRoot = override == null |
| 96 ? p.join(p.dirname(path), 'packages') | 96 ? p.join(p.dirname(path), 'packages') |
| 97 : override; | 97 : override; |
| 98 | 98 |
| 99 if (!new Directory(packageRoot).existsSync()) { | 99 if (!new Directory(packageRoot).existsSync()) { |
| 100 throw new LoadException(path, "Directory $packageRoot does not exist."); | 100 throw new LoadException(path, "Directory $packageRoot does not exist."); |
| 101 } | 101 } |
| 102 | 102 |
| 103 return p.toUri(packageRoot).toString(); | 103 return packageRoot; |
| 104 } | 104 } |
| 105 | 105 |
| 106 /// The library name must be globally unique, or the wrong library path may be | 106 /// The library name must be globally unique, or the wrong library path may be |
| 107 /// returned. | 107 /// returned. |
| 108 String libraryPath(Symbol libraryName, {String packageRoot}) { | 108 String libraryPath(Symbol libraryName, {String packageRoot}) { |
| 109 var lib = currentMirrorSystem().findLibrary(libraryName); | 109 var lib = currentMirrorSystem().findLibrary(libraryName); |
| 110 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); | 110 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); |
| 111 | 111 |
| 112 // TODO(nweiz): is there a way to avoid assuming this is being run next to a | 112 // TODO(nweiz): is there a way to avoid assuming this is being run next to a |
| 113 // packages directory?. | 113 // packages directory?. |
| 114 if (packageRoot == null) packageRoot = p.absolute('packages'); | 114 if (packageRoot == null) packageRoot = p.absolute('packages'); |
| 115 return p.join(packageRoot, p.fromUri(lib.uri.path)); | 115 return p.join(packageRoot, p.fromUri(lib.uri.path)); |
| 116 } | 116 } |
| OLD | NEW |