diff --git a/CHANGELOG.md b/CHANGELOG.md index f78cd7453..bec98e1eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/lib/src/runner/browser/browser.dart b/lib/src/runner/browser/browser.dart index be07d8a10..79583b6b2 100644 --- a/lib/src/runner/browser/browser.dart +++ b/lib/src/runner/browser/browser.dart @@ -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], @@ -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 diff --git a/pubspec.yaml b/pubspec.yaml index 8fb69bb5e..ee3b3d85a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 0.12.24+3 +version: 0.12.24+4 author: Dart Team description: A library for writing dart unit tests. homepage: https://github.com/dart-lang/test