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

Unified Diff: lib/src/runner/reporter/compact.dart

Issue 1175753002: Move some state-tracking to Engine. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Update pubspec version. Created 5 years, 6 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/runner/engine.dart ('k') | lib/src/runner/reporter/expanded.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/reporter/compact.dart
diff --git a/lib/src/runner/reporter/compact.dart b/lib/src/runner/reporter/compact.dart
index be6eb00566c2d0e56fc096314cf79f5c7f272877..a31e158231c4300a294fd115118a326493c8e84d 100644
--- a/lib/src/runner/reporter/compact.dart
+++ b/lib/src/runner/reporter/compact.dart
@@ -57,28 +57,18 @@ class CompactReporter {
/// A stopwatch that tracks the duration of the full run.
final _stopwatch = new Stopwatch();
- /// The set of tests that have completed and been marked as passing.
- final _passed = new Set<LiveTest>();
-
- /// The set of tests that have completed and been marked as skipped.
- final _skipped = new Set<LiveTest>();
-
- /// The set of tests that have completed and been marked as failing or error.
- final _failed = new Set<LiveTest>();
-
- /// The set of tests that are still running.
- final _active = new List<LiveTest>();
-
/// Whether [close] has been called.
bool _closed = false;
- /// The size of [_passed] last time a progress notification was printed.
+ /// The size of `_engine.passed` last time a progress notification was
+ /// printed.
int _lastProgressPassed;
- /// The size of [_skipped] last time a progress notification was printed.
+ /// The size of `_engine.skipped` last time a progress notification was printed.
int _lastProgressSkipped;
- /// The size of [_failed] last time a progress notification was printed.
+ /// The size of `_engine.failed` last time a progress notification was
+ /// printed.
int _lastProgressFailed;
/// The message printed for the last progress notification.
@@ -105,22 +95,13 @@ class CompactReporter {
_yellow = color ? '\u001b[33m' : '',
_noColor = color ? '\u001b[0m' : '' {
_engine.onTestStarted.listen((liveTest) {
- if (_active.isEmpty) _progressLine(_description(liveTest));
- _active.add(liveTest);
+ // If this is the first test to start, print a progress line so the user
+ // knows what's running.
+ if (_engine.active.length == 1) _progressLine(_description(liveTest));
_printedNewline = false;
liveTest.onStateChange.listen((state) {
if (state.status != Status.complete) return;
- _active.remove(liveTest);
-
- if (state.result != Result.success) {
- _passed.remove(liveTest);
- _failed.add(liveTest);
- } else if (liveTest.test.metadata.skip) {
- _skipped.add(liveTest);
- } else {
- _passed.add(liveTest);
- }
if (liveTest.test.metadata.skip &&
liveTest.test.metadata.skipReason != null) {
@@ -131,10 +112,10 @@ class CompactReporter {
} else {
// Always display the name of the oldest active test, unless testing
// is finished in which case display the last test to complete.
- if (_active.isEmpty) {
+ if (_engine.active.isEmpty) {
_progressLine(_description(liveTest));
} else {
- _progressLine(_description(_active.first));
+ _progressLine(_description(_engine.active.first));
}
_printedNewline = false;
@@ -198,7 +179,7 @@ class CompactReporter {
if (!success) {
_progressLine('Some tests failed.', color: _red);
print('');
- } else if (_passed.isEmpty) {
+ } else if (_engine.passed.isEmpty) {
_progressLine("All tests skipped.");
print('');
} else {
@@ -225,16 +206,16 @@ class CompactReporter {
/// color for [message].
bool _progressLine(String message, {String color}) {
// Print nothing if nothing has changed since the last progress line.
- if (_passed.length == _lastProgressPassed &&
- _skipped.length == _lastProgressSkipped &&
- _failed.length == _lastProgressFailed &&
+ if (_engine.passed.length == _lastProgressPassed &&
+ _engine.skipped.length == _lastProgressSkipped &&
+ _engine.failed.length == _lastProgressFailed &&
message == _lastProgressMessage) {
return false;
}
- _lastProgressPassed = _passed.length;
- _lastProgressSkipped = _skipped.length;
- _lastProgressFailed = _failed.length;
+ _lastProgressPassed = _engine.passed.length;
+ _lastProgressSkipped = _engine.skipped.length;
+ _lastProgressFailed = _engine.failed.length;
_lastProgressMessage = message;
if (color == null) color = '';
@@ -245,20 +226,20 @@ class CompactReporter {
buffer.write('\r${_timeString(duration)} ');
buffer.write(_green);
buffer.write('+');
- buffer.write(_passed.length);
+ buffer.write(_engine.passed.length);
buffer.write(_noColor);
- if (_skipped.isNotEmpty) {
+ if (_engine.skipped.isNotEmpty) {
buffer.write(_yellow);
buffer.write(' ~');
- buffer.write(_skipped.length);
+ buffer.write(_engine.skipped.length);
buffer.write(_noColor);
}
- if (_failed.isNotEmpty) {
+ if (_engine.failed.isNotEmpty) {
buffer.write(_red);
buffer.write(' -');
- buffer.write(_failed.length);
+ buffer.write(_engine.failed.length);
buffer.write(_noColor);
}
@@ -269,7 +250,7 @@ class CompactReporter {
// escape sequences too. Because these sequences are not visible characters,
// we make sure they are not counted towards the limit.
var nonVisible = 1 + _green.length + _noColor.length + color.length +
- (_failed.isEmpty ? 0 : _red.length + _noColor.length);
+ (_engine.failed.isEmpty ? 0 : _red.length + _noColor.length);
var length = buffer.length - nonVisible;
buffer.write(truncate(message, _lineLength - length));
buffer.write(_noColor);
« no previous file with comments | « lib/src/runner/engine.dart ('k') | lib/src/runner/reporter/expanded.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698