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 root directory of the Dart SDK. | 17 /// The root directory of the Dart SDK. |
18 final String sdkDir = | 18 final String sdkDir = |
19 p.dirname(p.dirname(Platform.executable)); | 19 p.dirname(p.dirname(Platform.executable)); |
20 | 20 |
21 /// The version of the Dart SDK currently in use. | 21 /// The version of the Dart SDK currently in use. |
22 final Version _sdkVersion = new Version.parse( | 22 final Version _sdkVersion = new Version.parse( |
23 new File(p.join(p.dirname(p.dirname(Platform.executable)), 'version')) | 23 new File(p.join(sdkDir, 'version')) |
24 .readAsStringSync().trim()); | 24 .readAsStringSync().trim()); |
25 | 25 |
26 /// Returns the current operating system. | 26 /// Returns the current operating system. |
27 final OperatingSystem currentOS = (() { | 27 final OperatingSystem currentOS = (() { |
28 var name = Platform.operatingSystem; | 28 var name = Platform.operatingSystem; |
29 var os = OperatingSystem.findByIoName(name); | 29 var os = OperatingSystem.findByIoName(name); |
30 if (os != null) return os; | 30 if (os != null) return os; |
31 | 31 |
32 throw new UnsupportedError('Unsupported operating system "$name".'); | 32 throw new UnsupportedError('Unsupported operating system "$name".'); |
33 })(); | 33 })(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 /// returned. | 132 /// returned. |
133 String libraryPath(Symbol libraryName, {String packageRoot}) { | 133 String libraryPath(Symbol libraryName, {String packageRoot}) { |
134 var lib = currentMirrorSystem().findLibrary(libraryName); | 134 var lib = currentMirrorSystem().findLibrary(libraryName); |
135 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); | 135 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); |
136 | 136 |
137 // TODO(nweiz): is there a way to avoid assuming this is being run next to a | 137 // TODO(nweiz): is there a way to avoid assuming this is being run next to a |
138 // packages directory?. | 138 // packages directory?. |
139 if (packageRoot == null) packageRoot = p.absolute('packages'); | 139 if (packageRoot == null) packageRoot = p.absolute('packages'); |
140 return p.join(packageRoot, p.fromUri(lib.uri.path)); | 140 return p.join(packageRoot, p.fromUri(lib.uri.path)); |
141 } | 141 } |
OLD | NEW |