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

Unified Diff: test/runner_test.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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/util/io.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner_test.dart
diff --git a/test/runner_test.dart b/test/runner_test.dart
index 5ea4717d9843aacb6cb7660f40bbc0fca2b657da..d1a992de32e6dd4a5f402038554d1700ca1af1ab 100644
--- a/test/runner_test.dart
+++ b/test/runner_test.dart
@@ -32,6 +32,14 @@ void main() {
}
""";
+final _usage = """
+Usage: pub run unittest:unittest [files or directories...]
+
+-h, --help Shows this usage information.
+ --[no-]color Whether to use terminal colors.
+ (auto-detected by default)
+""";
+
void main() {
setUp(() {
_sandbox = Directory.systemTemp.createTempSync('unittest_').path;
@@ -46,10 +54,7 @@ void main() {
expect(result.stdout, equals("""
Runs tests in this package.
-Usage: pub run unittest:unittest [files or directories...]
-
--h, --help Shows this usage information.
-"""));
+$_usage"""));
expect(result.exitCode, equals(exit_codes.success));
});
@@ -59,10 +64,7 @@ Usage: pub run unittest:unittest [files or directories...]
expect(result.stderr, equals("""
Could not find an option named "asdf".
-Usage: pub run unittest:unittest [files or directories...]
-
--h, --help Shows this usage information.
-"""));
+$_usage"""));
expect(result.exitCode, equals(exit_codes.usage));
});
@@ -215,6 +217,15 @@ Usage: pub run unittest:unittest [files or directories...]
expect(result.stdout, contains("Some tests failed."));
});
});
+
+ group("flags", () {
+ test("with the --color flag, uses colors", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
+ var result = _runUnittest(["--color", "test.dart"]);
+ // This is the color code for red.
+ expect(result.stdout, contains("\u001b[31m"));
+ });
+ });
}
ProcessResult _runUnittest(List<String> args) =>
« no previous file with comments | « lib/src/util/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698