Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

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

Issue 948113004: Support Dart 1.8.0. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/dart.dart ('k') | lib/src/isolate_wrapper.dart » ('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.io; 5 library unittest.io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as p;
11
12 /// Returns whether the current Dart version supports [Isolate.kill].
13 final bool supportsIsolateKill = _supportsIsolateKill;
14 bool get _supportsIsolateKill {
15 // This isn't 100% accurate, since early 1.9 dev releases didn't support
16 // Isolate.kill(), but it's very unlikely anyone will be using them.
17 // TODO(nweiz): remove this when we no longer support older Dart versions.
18 var path = p.join(p.dirname(p.dirname(Platform.executable)), 'version');
19 return new File(path).readAsStringSync().startsWith('1.9');
20 }
21
10 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". 22 // TODO(nweiz): Make this check [stdioType] once that works within "pub run".
11 /// Whether "special" strings such as Unicode characters or color escapes are 23 /// Whether "special" strings such as Unicode characters or color escapes are
12 /// safe to use. 24 /// safe to use.
13 /// 25 ///
14 /// On Windows or when not printing to a terminal, only printable ASCII 26 /// On Windows or when not printing to a terminal, only printable ASCII
15 /// characters should be used. 27 /// characters should be used.
16 bool get canUseSpecialChars => 28 bool get canUseSpecialChars =>
17 Platform.operatingSystem != 'windows' && 29 Platform.operatingSystem != 'windows' &&
18 Platform.environment["_UNITTEST_USE_COLOR"] != "false"; 30 Platform.environment["_UNITTEST_USE_COLOR"] != "false";
19 31
(...skipping 14 matching lines...) Expand all
34 /// [fn] completes to. 46 /// [fn] completes to.
35 Future withTempDir(Future fn(String path)) { 47 Future withTempDir(Future fn(String path)) {
36 return new Future.sync(() { 48 return new Future.sync(() {
37 // TODO(nweiz): Empirically test whether sync or async functions perform 49 // TODO(nweiz): Empirically test whether sync or async functions perform
38 // better here when starting a bunch of isolates. 50 // better here when starting a bunch of isolates.
39 var tempDir = Directory.systemTemp.createTempSync('unittest_'); 51 var tempDir = Directory.systemTemp.createTempSync('unittest_');
40 return new Future.sync(() => fn(tempDir.path)) 52 return new Future.sync(() => fn(tempDir.path))
41 .whenComplete(() => tempDir.deleteSync(recursive: true)); 53 .whenComplete(() => tempDir.deleteSync(recursive: true));
42 }); 54 });
43 } 55 }
OLDNEW
« no previous file with comments | « lib/src/dart.dart ('k') | lib/src/isolate_wrapper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698