Skip to content

Commit

Permalink
Drain STDOUT and STDIN for Browser process (#681)
Browse files Browse the repository at this point in the history
* Drain and ignore

* add changelog and pubspec
  • Loading branch information
grouma authored Sep 12, 2017
1 parent dd44d29 commit 2263344
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.12.24+4

* Drain browser process `stdout` and `stdin`. This resolves test flakiness, especially in Travis
with the `Precise` image.

## 0.12.24+3

* Extend `deserializeTimeout`.
Expand Down
10 changes: 10 additions & 0 deletions lib/src/runner/browser/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ abstract class Browser {
Future get onExit => _onExitCompleter.future;
final _onExitCompleter = new Completer();

Future _drainAndIgnore(Stream s) async {
try {
await s.drain();
} on StateError catch (_) {}
}

/// Creates a new browser.
///
/// This is intended to be called by subclasses. They pass in [startBrowser],
Expand All @@ -65,6 +71,10 @@ abstract class Browser {
var process = await startBrowser();
_processCompleter.complete(process);

// If we don't drain the stdout and stderr the process can hang.
await Future.wait(
[_drainAndIgnore(process.stdout), _drainAndIgnore(process.stderr)]);

var exitCode = await process.exitCode;

// This hack dodges an otherwise intractable race condition. When the user
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test
version: 0.12.24+3
version: 0.12.24+4
author: Dart Team <[email protected]>
description: A library for writing dart unit tests.
homepage: https://github.com/dart-lang/test
Expand Down

0 comments on commit 2263344

Please sign in to comment.