Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 13 additions & 3 deletions lib/src/runner/browser/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 (_) {}
}

Expand All @@ -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;

Expand Down Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you file a dart:io bug for this? If so, refer to it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// 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.
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.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
Expand Down