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

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

Issue 8776049: Do not show percentages when we don't know what they are in test progress indication. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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') | tools/testing/dart/test_runner.dart » ('j') | 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 4c395adeae1931a9ce938cc11beb83aec7c62a8a..fb51dbd3317e24daee2db94669d2d68b562a99ef 100644
--- a/tools/testing/dart/test_progress.dart
+++ b/tools/testing/dart/test_progress.dart
@@ -46,6 +46,11 @@ class ProgressIndicator {
_printDoneProgress(test);
}
+ void allTestsKnown() {
+ if (!_allTestsKnown) SummaryReport.printReport();
+ _allTestsKnown = true;
+ }
+
abstract allDone();
abstract _printStartProgress();
abstract _printDoneProgress();
@@ -114,44 +119,52 @@ class ProgressIndicator {
int _foundTests = 0;
int _passedTests = 0;
int _failedTests = 0;
+ bool _allTestsKnown = false;
Date _startTime;
}
-class CompactProgressIndicator extends ProgressIndicator {
- CompactProgressIndicator(Date startTime) : super(startTime);
+class CompactIndicator extends ProgressIndicator {
+ CompactIndicator(Date startTime) : super(startTime);
void allDone() {
- SummaryReport.printReport();
stdout.write('\n'.charCodes());
stdout.close();
+ exit(_failedTests > 0 ? 1 : 0);
}
+ void _printStartProgress(TestCase test) => _printProgress();
+ void _printDoneProgress(TestCase test) => _printProgress();
+
+ String _nextSpinner() {
+ _spinnerIndex = (_spinnerIndex + 1) % 4;
+ return _spinners[_spinnerIndex];
+ }
+
+ static int _spinnerIndex = 0;
+ static List<String> _spinners = const ['- ', '\\ ', '| ', '/ '];
+}
+
+
+class CompactProgressIndicator extends CompactIndicator {
+ CompactProgressIndicator(Date startTime) : super(startTime);
+
void _printProgress() {
var percent = ((_completedTests() / _foundTests) * 100).floor().toString();
- var percentPadded = _pad(percent, 5);
+ var progressPadded = _pad(_allTestsKnown ? percent : _nextSpinner(), 5);
var passedPadded = _pad(_passedTests.toString(), 5);
var failedPadded = _pad(_failedTests.toString(), 5);
var progressLine =
- '\r[${_timeString()} | $percentPadded% | ' +
+ '\r[${_timeString()} | $progressPadded% | ' +
'+$passedPadded | -$failedPadded]';
stdout.write(progressLine.charCodes());
}
-
- void _printStartProgress(TestCase test) => _printProgress();
- void _printDoneProgress(TestCase test) => _printProgress();
}
-class ColorProgressIndicator extends ProgressIndicator {
+class ColorProgressIndicator extends CompactIndicator {
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;
@@ -166,11 +179,11 @@ class ColorProgressIndicator extends ProgressIndicator {
void _printProgress() {
var percent = ((_completedTests() / _foundTests) * 100).floor().toString();
- var percentPadded = _pad(percent, 5);
+ var progressPadded = _pad(_allTestsKnown ? percent : _nextSpinner(), 5);
var passedPadded = _pad(_passedTests.toString(), 5);
var failedPadded = _pad(_failedTests.toString(), 5);
var progressLine = [];
- progressLine.addAll('\r[${_timeString()} | $percentPadded% | '.charCodes());
+ progressLine.addAll('\r[${_timeString()} | $progressPadded% | '.charCodes());
addColorWrapped(progressLine, '+$passedPadded ', GREEN);
progressLine.addAll('| '.charCodes());
var failedColor = (_failedTests != 0) ? RED : NONE;
@@ -178,19 +191,15 @@ class ColorProgressIndicator extends ProgressIndicator {
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);
void allDone() {
_printStatus();
- SummaryReport.printReport();
+ exit(_failedTests > 0 ? 1 : 0);
}
void _printStartProgress(TestCase test) {
@@ -211,7 +220,7 @@ class VerboseProgressIndicator extends ProgressIndicator {
void allDone() {
_printStatus();
- SummaryReport.printReport();
+ exit(_failedTests > 0 ? 1 : 0);
}
void _printStartProgress(TestCase test) {
@@ -233,7 +242,7 @@ class StatusProgressIndicator extends ProgressIndicator {
void allDone() {
_printStatus();
- SummaryReport.printReport();
+ exit(_failedTests > 0 ? 1 : 0);
}
void _printStartProgress(TestCase test) {
@@ -249,6 +258,7 @@ class BuildbotProgressIndicator extends ProgressIndicator {
void allDone() {
_printStatus();
+ exit(_failedTests > 0 ? 1 : 0);
}
void _printStartProgress(TestCase test) {
« no previous file with comments | « tools/testing/dart/test_options.dart ('k') | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698