Chromium Code Reviews

Side by Side Diff: lib/src/util/io.dart

Issue 1049113004: Improve the detection of which platforms support Isolate.kill. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...)
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...)
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 }
OLDNEW
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine