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 |
11 import 'package:path/path.dart' as p; | 11 import 'package:path/path.dart' as p; |
12 import 'package:pub_semver/pub_semver.dart'; | 12 import 'package:pub_semver/pub_semver.dart'; |
13 | 13 |
14 import '../backend/operating_system.dart'; | 14 import '../backend/operating_system.dart'; |
15 import '../runner/application_exception.dart'; | 15 import '../runner/application_exception.dart'; |
16 | 16 |
17 /// The ASCII code for a newline character. | 17 /// The ASCII code for a newline character. |
18 const _newline = 0xA; | 18 const _newline = 0xA; |
19 | 19 |
20 /// The ASCII code for a carriage return character. | 20 /// The ASCII code for a carriage return character. |
21 const _carriageReturn = 0xD; | 21 const _carriageReturn = 0xD; |
22 | 22 |
23 /// The root directory of the Dart SDK. | 23 /// The root directory of the Dart SDK. |
24 final String sdkDir = (() { | 24 final String sdkDir = (() { |
25 // TODO(kevmoo): work-around for accessing the SDK root dartbug.com/16994 | 25 // TODO(kevmoo): work-around for accessing the SDK root dartbug.com/16994 |
26 var path = new File(Platform.executable).resolveSymbolicLinksSync(); | 26 // |
| 27 // Don't resolve symlinks on Windows because of issue 133. Once the TODO above |
| 28 // is resolved, we won't have to do explicit symlink resolution anyway. |
| 29 var path = Platform.isWindows |
| 30 ? Platform.executable |
| 31 : new File(Platform.executable).resolveSymbolicLinksSync(); |
27 return p.dirname(p.dirname(path)); | 32 return p.dirname(p.dirname(path)); |
28 })(); | 33 })(); |
29 | 34 |
30 /// The version of the Dart SDK currently in use. | 35 /// The version of the Dart SDK currently in use. |
31 final Version _sdkVersion = new Version.parse( | 36 final Version _sdkVersion = new Version.parse( |
32 new File(p.join(sdkDir, 'version')) | 37 new File(p.join(sdkDir, 'version')) |
33 .readAsStringSync().trim()); | 38 .readAsStringSync().trim()); |
34 | 39 |
35 /// Returns the current operating system. | 40 /// Returns the current operating system. |
36 final OperatingSystem currentOS = (() { | 41 final OperatingSystem currentOS = (() { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 /// returned. | 161 /// returned. |
157 String libraryPath(Symbol libraryName, {String packageRoot}) { | 162 String libraryPath(Symbol libraryName, {String packageRoot}) { |
158 var lib = currentMirrorSystem().findLibrary(libraryName); | 163 var lib = currentMirrorSystem().findLibrary(libraryName); |
159 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); | 164 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); |
160 | 165 |
161 // TODO(nweiz): is there a way to avoid assuming this is being run next to a | 166 // TODO(nweiz): is there a way to avoid assuming this is being run next to a |
162 // packages directory?. | 167 // packages directory?. |
163 if (packageRoot == null) packageRoot = p.absolute('packages'); | 168 if (packageRoot == null) packageRoot = p.absolute('packages'); |
164 return p.join(packageRoot, p.fromUri(lib.uri.path)); | 169 return p.join(packageRoot, p.fromUri(lib.uri.path)); |
165 } | 170 } |
OLD | NEW |