Skip to content

Commit 2263344

Browse files
authored
Drain STDOUT and STDIN for Browser process (#681)
* Drain and ignore * add changelog and pubspec
1 parent dd44d29 commit 2263344

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.12.24+4
2+
3+
* Drain browser process `stdout` and `stdin`. This resolves test flakiness, especially in Travis
4+
with the `Precise` image.
5+
16
## 0.12.24+3
27

38
* Extend `deserializeTimeout`.

lib/src/runner/browser/browser.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ abstract class Browser {
5151
Future get onExit => _onExitCompleter.future;
5252
final _onExitCompleter = new Completer();
5353

54+
Future _drainAndIgnore(Stream s) async {
55+
try {
56+
await s.drain();
57+
} on StateError catch (_) {}
58+
}
59+
5460
/// Creates a new browser.
5561
///
5662
/// This is intended to be called by subclasses. They pass in [startBrowser],
@@ -65,6 +71,10 @@ abstract class Browser {
6571
var process = await startBrowser();
6672
_processCompleter.complete(process);
6773

74+
// If we don't drain the stdout and stderr the process can hang.
75+
await Future.wait(
76+
[_drainAndIgnore(process.stdout), _drainAndIgnore(process.stderr)]);
77+
6878
var exitCode = await process.exitCode;
6979

7080
// This hack dodges an otherwise intractable race condition. When the user

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test
2-
version: 0.12.24+3
2+
version: 0.12.24+4
33
author: Dart Team <[email protected]>
44
description: A library for writing dart unit tests.
55
homepage: https://github.com/dart-lang/test

0 commit comments

Comments
 (0)