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

Unified Diff: tools/testing/dart/test_progress.dart

Issue 8772044: Add color indication to progress. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Line length Created 9 years 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 | « tools/testing/dart/test_options.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_progress.dart
diff --git a/tools/testing/dart/test_progress.dart b/tools/testing/dart/test_progress.dart
index ddee196e3a020687bba44e4eeb1f34023e29182d..4c395adeae1931a9ce938cc11beb83aec7c62a8a 100644
--- a/tools/testing/dart/test_progress.dart
+++ b/tools/testing/dart/test_progress.dart
@@ -14,6 +14,8 @@ class ProgressIndicator {
switch (name) {
case 'compact':
return new CompactProgressIndicator(startTime);
+ case 'color':
+ return new ColorProgressIndicator(startTime);
case 'line':
return new LineProgressIndicator(startTime);
case 'verbose':
@@ -141,6 +143,48 @@ class CompactProgressIndicator extends ProgressIndicator {
}
+class ColorProgressIndicator extends ProgressIndicator {
+ ColorProgressIndicator(Date startTime) : super(startTime);
+
+ void allDone() {
+ SummaryReport.printReport();
+ stdout.write('\n'.charCodes());
+ stdout.close();
+ }
+
+ static int GREEN = 32;
+ static int RED = 31;
+ static int NONE = 0;
+
+ addColorWrapped(List<int> codes, String string, int color) {
+ codes.add(27);
+ codes.addAll('[${color}m'.charCodes());
+ codes.addAll(string.charCodes());
+ codes.add(27);
+ codes.addAll('[0m'.charCodes());
+ }
+
+ void _printProgress() {
+ var percent = ((_completedTests() / _foundTests) * 100).floor().toString();
+ var percentPadded = _pad(percent, 5);
+ var passedPadded = _pad(_passedTests.toString(), 5);
+ var failedPadded = _pad(_failedTests.toString(), 5);
+ var progressLine = [];
+ progressLine.addAll('\r[${_timeString()} | $percentPadded% | '.charCodes());
+ addColorWrapped(progressLine, '+$passedPadded ', GREEN);
+ progressLine.addAll('| '.charCodes());
+ var failedColor = (_failedTests != 0) ? RED : NONE;
+ addColorWrapped(progressLine, '-$failedPadded', failedColor);
+ progressLine.addAll(']'.charCodes());
+ stdout.write(progressLine);
+ }
+
+ void _printStartProgress(TestCase test) => _printProgress();
+ void _printDoneProgress(TestCase test) => _printProgress();
+}
+
+
+
class LineProgressIndicator extends ProgressIndicator {
LineProgressIndicator(Date startTime) : super(startTime);
« no previous file with comments | « tools/testing/dart/test_options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698