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

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

Issue 961003005: Add a flag to control the use of color in the test runner. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 9 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/runner/console_reporter.dart ('k') | test/runner_test.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.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 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 15 matching lines...) Expand all
26 // TODO(nweiz): Make this check [stdioType] once that works within "pub run". 26 // TODO(nweiz): Make this check [stdioType] once that works within "pub run".
27 /// Whether "special" strings such as Unicode characters or color escapes are 27 /// Whether "special" strings such as Unicode characters or color escapes are
28 /// safe to use. 28 /// safe to use.
29 /// 29 ///
30 /// On Windows or when not printing to a terminal, only printable ASCII 30 /// On Windows or when not printing to a terminal, only printable ASCII
31 /// characters should be used. 31 /// characters should be used.
32 bool get canUseSpecialChars => 32 bool get canUseSpecialChars =>
33 Platform.operatingSystem != 'windows' && 33 Platform.operatingSystem != 'windows' &&
34 Platform.environment["_UNITTEST_USE_COLOR"] != "false"; 34 Platform.environment["_UNITTEST_USE_COLOR"] != "false";
35 35
36 /// Gets a "special" string (ANSI escape or Unicode).
37 ///
38 /// On Windows or when not printing to a terminal, returns something else since
39 /// those aren't supported.
40 String getSpecial(String special, [String onWindows = '']) =>
41 canUseSpecialChars ? special : onWindows;
42
43 /// Creates a temporary directory and passes its path to [fn]. 36 /// Creates a temporary directory and passes its path to [fn].
44 /// 37 ///
45 /// Once the [Future] returned by [fn] completes, the temporary directory and 38 /// Once the [Future] returned by [fn] completes, the temporary directory and
46 /// all its contents are deleted. [fn] can also return `null`, in which case 39 /// all its contents are deleted. [fn] can also return `null`, in which case
47 /// the temporary directory is deleted immediately afterwards. 40 /// the temporary directory is deleted immediately afterwards.
48 /// 41 ///
49 /// Returns a future that completes to the value that the future returned from 42 /// Returns a future that completes to the value that the future returned from
50 /// [fn] completes to. 43 /// [fn] completes to.
51 Future withTempDir(Future fn(String path)) { 44 Future withTempDir(Future fn(String path)) {
52 return new Future.sync(() { 45 return new Future.sync(() {
(...skipping 14 matching lines...) Expand all
67 } 60 }
68 61
69 // IPv6 addresses in URLs need to be enclosed in square brackets to avoid 62 // IPv6 addresses in URLs need to be enclosed in square brackets to avoid
70 // URL ambiguity with the ":" in the address. 63 // URL ambiguity with the ":" in the address.
71 if (address.type == InternetAddressType.IP_V6) { 64 if (address.type == InternetAddressType.IP_V6) {
72 return new Uri(scheme: "http", host: "[${address.address}]", port: port); 65 return new Uri(scheme: "http", host: "[${address.address}]", port: port);
73 } 66 }
74 67
75 return new Uri(scheme: "http", host: address.address, port: port); 68 return new Uri(scheme: "http", host: address.address, port: port);
76 } 69 }
OLDNEW
« no previous file with comments | « lib/src/runner/console_reporter.dart ('k') | test/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698