Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Run the test's heartbeat whenever the process emits output #17

Merged
merged 1 commit into from
Jan 14, 2020
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 1.0.5-dev
## 1.0.5

* Don't allow the test to time out as long as the process is emitting output.

## 1.0.4

Expand Down
10 changes: 10 additions & 0 deletions lib/test_process.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ class TestProcess {
// Call [split] explicitly because we don't want to log overridden
// [stdoutStream] or [stderrStream] output.
_stdoutSplitter.split().listen((line) {
_heartbeat();
if (forwardStdio) print(line);
_log.add(' $line');
});

_stderrSplitter.split().listen((line) {
_heartbeat();
if (forwardStdio) print(line);
_log.add('[e] $line');
});
Expand Down Expand Up @@ -232,4 +234,12 @@ class TestProcess {
expect(exitCode, expectedExitCode,
reason: 'Process `$description` had an unexpected exit code.');
}

/// Signal to the test runner that the test is still making progress and
/// shouldn't time out.
void _heartbeat() {
// Interacting with the test runner's asynchronous expectation logic will
// notify it that the test is alive.
expectAsync0(() {})();
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_process
version: 1.0.5-dev
version: 1.0.5

description: A package for testing subprocesses.
homepage: https://github.com/dart-lang/test_process
Expand Down