| 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 unittest.util.io; | 5 library unittest.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 21 matching lines...) Expand all Loading... |
| 32 return p.dirname(p.dirname(p.dirname(pathToIo))); | 32 return p.dirname(p.dirname(p.dirname(pathToIo))); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /// Returns whether the current Dart version supports [Isolate.kill]. | 35 /// Returns whether the current Dart version supports [Isolate.kill]. |
| 36 final bool supportsIsolateKill = _supportsIsolateKill; | 36 final bool supportsIsolateKill = _supportsIsolateKill; |
| 37 bool get _supportsIsolateKill { | 37 bool get _supportsIsolateKill { |
| 38 // This isn't 100% accurate, since early 1.9 dev releases didn't support | 38 // This isn't 100% accurate, since early 1.9 dev releases didn't support |
| 39 // Isolate.kill(), but it's very unlikely anyone will be using them. | 39 // Isolate.kill(), but it's very unlikely anyone will be using them. |
| 40 // TODO(nweiz): remove this when we no longer support older Dart versions. | 40 // TODO(nweiz): remove this when we no longer support older Dart versions. |
| 41 var path = p.join(p.dirname(p.dirname(Platform.executable)), 'version'); | 41 var path = p.join(p.dirname(p.dirname(Platform.executable)), 'version'); |
| 42 return new File(path).readAsStringSync().startsWith('1.9'); | 42 return !new File(path).readAsStringSync().startsWith('1.8'); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". | 45 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". |
| 46 /// Whether "special" strings such as Unicode characters or color escapes are | 46 /// Whether "special" strings such as Unicode characters or color escapes are |
| 47 /// safe to use. | 47 /// safe to use. |
| 48 /// | 48 /// |
| 49 /// On Windows or when not printing to a terminal, only printable ASCII | 49 /// On Windows or when not printing to a terminal, only printable ASCII |
| 50 /// characters should be used. | 50 /// characters should be used. |
| 51 bool get canUseSpecialChars => | 51 bool get canUseSpecialChars => |
| 52 Platform.operatingSystem != 'windows' && | 52 Platform.operatingSystem != 'windows' && |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |