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 p.dirname(p.dirname(Platform.executable)); | 25 // TODO(kevmoo): work-around for accessing the SDK root dartbug.com/16994 |
| 26 var path = new File(Platform.executable).resolveSymbolicLinksSync(); |
| 27 return p.dirname(p.dirname(path)); |
| 28 })(); |
26 | 29 |
27 /// The version of the Dart SDK currently in use. | 30 /// The version of the Dart SDK currently in use. |
28 final Version _sdkVersion = new Version.parse( | 31 final Version _sdkVersion = new Version.parse( |
29 new File(p.join(sdkDir, 'version')) | 32 new File(p.join(sdkDir, 'version')) |
30 .readAsStringSync().trim()); | 33 .readAsStringSync().trim()); |
31 | 34 |
32 /// Returns the current operating system. | 35 /// Returns the current operating system. |
33 final OperatingSystem currentOS = (() { | 36 final OperatingSystem currentOS = (() { |
34 var name = Platform.operatingSystem; | 37 var name = Platform.operatingSystem; |
35 var os = OperatingSystem.findByIoName(name); | 38 var os = OperatingSystem.findByIoName(name); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 /// returned. | 156 /// returned. |
154 String libraryPath(Symbol libraryName, {String packageRoot}) { | 157 String libraryPath(Symbol libraryName, {String packageRoot}) { |
155 var lib = currentMirrorSystem().findLibrary(libraryName); | 158 var lib = currentMirrorSystem().findLibrary(libraryName); |
156 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); | 159 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); |
157 | 160 |
158 // TODO(nweiz): is there a way to avoid assuming this is being run next to a | 161 // TODO(nweiz): is there a way to avoid assuming this is being run next to a |
159 // packages directory?. | 162 // packages directory?. |
160 if (packageRoot == null) packageRoot = p.absolute('packages'); | 163 if (packageRoot == null) packageRoot = p.absolute('packages'); |
161 return p.join(packageRoot, p.fromUri(lib.uri.path)); | 164 return p.join(packageRoot, p.fromUri(lib.uri.path)); |
162 } | 165 } |
OLD | NEW |