Skip to content

Commit 5652c6d

Browse files
authored
Fix test hang and prep for release - 0.12.26+1 (#715)
1 parent 9bc2e03 commit 5652c6d

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
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.26+1
2+
3+
* Fix lower bound on package `stack_trace`. Now 1.6.0.
4+
* Manually close browser process streams to prevent test hangs.
5+
16
## 0.12.26
27

38
* The `spawnHybridUri()` function now allows root-relative URLs, which are

lib/src/runner/browser/browser.dart

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

54+
/// Standard IO streams for the underlying browser process.
55+
final _ioSubscriptions = <StreamSubscription>[];
56+
5457
Future _drainAndIgnore(Stream s) async {
5558
try {
56-
await s.drain();
59+
_ioSubscriptions.add(s.listen(null, cancelOnError: true));
5760
} on StateError catch (_) {}
5861
}
5962

@@ -72,8 +75,8 @@ abstract class Browser {
7275
_processCompleter.complete(process);
7376

7477
// If we don't drain the stdout and stderr the process can hang.
75-
await Future.wait(
76-
[_drainAndIgnore(process.stdout), _drainAndIgnore(process.stderr)]);
78+
_drainAndIgnore(process.stdout);
79+
_drainAndIgnore(process.stderr);
7780

7881
var exitCode = await process.exitCode;
7982

@@ -120,6 +123,13 @@ abstract class Browser {
120123
Future close() {
121124
_closed = true;
122125

126+
// If we don't manually close the stream the test runner can hang.
127+
// For example this happens with Chrome Headless.
128+
// See SDK issue: https://github.com/dart-lang/sdk/issues/31264
129+
for (var stream in _ioSubscriptions) {
130+
stream.cancel();
131+
}
132+
123133
_process.then((process) {
124134
// Dartium has a difficult time being killed on Linux. To ensure it is
125135
// properly closed, find all children processes and kill those first.

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.26
2+
version: 0.12.26+1
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)