From 5652c6dcae8a6b2d270ec9762b1f35b347976157 Mon Sep 17 00:00:00 2001 From: Gary Roumanis <groumanis@gmail.com> Date: Wed, 1 Nov 2017 15:58:30 -0700 Subject: [PATCH] Fix test hang and prep for release - 0.12.26+1 (#715) --- CHANGELOG.md | 5 +++++ lib/src/runner/browser/browser.dart | 16 +++++++++++++--- pubspec.yaml | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94782221..e3c59dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.12.26+1 + +* Fix lower bound on package `stack_trace`. Now 1.6.0. +* Manually close browser process streams to prevent test hangs. + ## 0.12.26 * The `spawnHybridUri()` function now allows root-relative URLs, which are diff --git a/lib/src/runner/browser/browser.dart b/lib/src/runner/browser/browser.dart index e1602317..e587f613 100644 --- a/lib/src/runner/browser/browser.dart +++ b/lib/src/runner/browser/browser.dart @@ -51,9 +51,12 @@ abstract class Browser { Future get onExit => _onExitCompleter.future; final _onExitCompleter = new Completer(); + /// Standard IO streams for the underlying browser process. + final _ioSubscriptions = <StreamSubscription>[]; + Future _drainAndIgnore(Stream s) async { try { - await s.drain(); + _ioSubscriptions.add(s.listen(null, cancelOnError: true)); } on StateError catch (_) {} } @@ -72,8 +75,8 @@ abstract class Browser { _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)]); + _drainAndIgnore(process.stdout); + _drainAndIgnore(process.stderr); var exitCode = await process.exitCode; @@ -120,6 +123,13 @@ abstract class Browser { Future close() { _closed = true; + // If we don't manually close the stream the test runner can hang. + // For example this happens with Chrome Headless. + // See SDK issue: https://github.com/dart-lang/sdk/issues/31264 + for (var stream in _ioSubscriptions) { + stream.cancel(); + } + _process.then((process) { // Dartium has a difficult time being killed on Linux. To ensure it is // properly closed, find all children processes and kill those first. diff --git a/pubspec.yaml b/pubspec.yaml index f3e561fb..8cdb1fc5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 0.12.26 +version: 0.12.26+1 author: Dart Team <misc@dartlang.org> description: A library for writing dart unit tests. homepage: https://github.com/dart-lang/test -- GitLab