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

Unified Diff: pkg/unittest/lib/vm_config.dart

Issue 14917022: Added color coding to test results in VM config. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
« pkg/unittest/lib/src/config.dart ('K') | « pkg/unittest/lib/src/config.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/vm_config.dart
===================================================================
--- pkg/unittest/lib/vm_config.dart (revision 22469)
+++ pkg/unittest/lib/vm_config.dart (working copy)
@@ -11,6 +11,32 @@
import 'unittest.dart';
class VMConfiguration extends Configuration {
+ // Color constants used for generating messages.
+ final String GREEN_COLOR = '\u001b[32m';
+ final String RED_COLOR = '\u001b[31m';
+ final String MAGENTA_COLOR = '\u001b[35m';
+ final String NO_COLOR = '\u001b[0m';
+
+ // We make this public so the user can turn it off if they want.
+ bool useColor;
+
+ VMConfiguration() :
+ super(), useColor = stdioType(stdout) == StdioType.TERMINAL;
+
+ String formatResult(TestCase testCase) {
+ String result = super.formatResult(testCase);
+ if (useColor) {
+ if (testCase.result == PASS) {
+ return "${GREEN_COLOR}${result}${NO_COLOR}";
+ } else if (testCase.result == FAIL) {
+ return "${RED_COLOR}${result}${NO_COLOR}";
+ } else if (testCase.result == ERROR) {
+ return "${MAGENTA_COLOR}${result}${NO_COLOR}";
+ }
+ }
+ return result;
+ }
+
void onDone(bool success) {
try {
super.onDone(success);
« pkg/unittest/lib/src/config.dart ('K') | « pkg/unittest/lib/src/config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698