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

Unified Diff: lib/src/backend/live_test_controller.dart

Issue 1044953004: Gracefully handle tests that print. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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/backend/live_test.dart ('k') | lib/src/runner/browser/iframe_listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/backend/live_test_controller.dart
diff --git a/lib/src/backend/live_test_controller.dart b/lib/src/backend/live_test_controller.dart
index 17b8bcfdd30469a7643356e6f9168b184f0cc11d..a1a0d3a5efde2131b932a215a922979ab1cf6683 100644
--- a/lib/src/backend/live_test_controller.dart
+++ b/lib/src/backend/live_test_controller.dart
@@ -32,6 +32,8 @@ class _LiveTest extends LiveTest {
Stream<AsyncError> get onError => _controller._onErrorController.stream;
+ Stream<String> get onPrint => _controller._onPrintController.stream;
+
Future get onComplete => _controller.completer.future;
Future run() => _controller._run();
@@ -76,10 +78,24 @@ class LiveTestController {
var _state = const State(Status.pending, Result.success);
/// The controller for [LiveTest.onStateChange].
- final _onStateChangeController = new StreamController<State>.broadcast();
+ ///
+ /// This is synchronous to ensure that events are well-ordered across multiple
+ /// streams.
+ final _onStateChangeController = new StreamController<State>
+ .broadcast(sync: true);
/// The controller for [LiveTest.onError].
- final _onErrorController = new StreamController<AsyncError>.broadcast();
+ ///
+ /// This is synchronous to ensure that events are well-ordered across multiple
+ /// streams.
+ final _onErrorController = new StreamController<AsyncError>
+ .broadcast(sync: true);
+
+ /// The controller for [LiveTest.onPrint].
+ ///
+ /// This is synchronous to ensure that events are well-ordered across multiple
+ /// streams.
+ final _onPrintController = new StreamController<String>.broadcast(sync: true);
/// The completer for [LiveTest.onComplete];
final completer = new Completer();
@@ -130,6 +146,9 @@ class LiveTestController {
_onStateChangeController.add(newState);
}
+ /// Emits a line printed by the test over [LiveTest.onPrint].
+ void print(String line) => _onPrintController.add(line);
+
/// A wrapper for [_onRun] that ensures that it follows the guarantees for
/// [LiveTest.run].
Future _run() {
« no previous file with comments | « lib/src/backend/live_test.dart ('k') | lib/src/runner/browser/iframe_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698