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

Unified Diff: lib/src/runner/engine.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 | « no previous file | lib/src/runner/reporter/compact.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/engine.dart
diff --git a/lib/src/runner/engine.dart b/lib/src/runner/engine.dart
index ff6b4f6ff6338341392e58150438dff840f23604..73d48466f642df709283d78a90add734b8e6e0b7 100644
--- a/lib/src/runner/engine.dart
+++ b/lib/src/runner/engine.dart
@@ -7,6 +7,7 @@ library test.runner.engine;
import 'dart:async';
import 'dart:collection';
+import 'package:collection/collection.dart';
import 'package:pool/pool.dart';
import '../backend/live_test.dart';
@@ -55,6 +56,22 @@ class Engine {
Stream<LiveTest> get onTestStarted => _onTestStartedController.stream;
final _onTestStartedController = new StreamController<LiveTest>.broadcast();
+ /// The set of tests that have completed and been marked as passing.
+ Set<LiveTest> get passed => new UnmodifiableSetView(_passed);
+ final _passed = new Set<LiveTest>();
+
+ /// The set of tests that have completed and been marked as skipped.
+ Set<LiveTest> get skipped => new UnmodifiableSetView(_skipped);
+ final _skipped = new Set<LiveTest>();
+
+ /// The set of tests that have completed and been marked as failing or error.
+ Set<LiveTest> get failed => new UnmodifiableSetView(_failed);
+ final _failed = new Set<LiveTest>();
+
+ /// The tests that are still running, in the order they begain running.
+ List<LiveTest> get active => new UnmodifiableListView(_active);
+ final _active = new List<LiveTest>();
+
/// Returns the tests in [suites] grouped by suite.
///
/// Also replaces tests marked as "skip" with dummy [LiveTest]s.
@@ -104,6 +121,23 @@ class Engine {
return Future.forEach(suite, (liveTest) async {
// TODO(nweiz): Just "return;" when issue 23200 is fixed.
if (_closed) return null;
+
+ _active.add(liveTest);
+
+ 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);
+ }
+ });
+
_onTestStartedController.add(liveTest);
// First, schedule a microtask to ensure that [onTestStarted] fires
« no previous file with comments | « no previous file | lib/src/runner/reporter/compact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698