Run the test's heartbeat whenever the process emits output (#17)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2b55a6..6afc2e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/lib/test_process.dart b/lib/test_process.dart
index d0f15a1..d9dff5d 100644
--- a/lib/test_process.dart
+++ b/lib/test_process.dart
@@ -134,11 +134,13 @@
// 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');
});
@@ -232,4 +234,12 @@
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(() {})();
+ }
}
diff --git a/pubspec.yaml b/pubspec.yaml
index efaeef3..cec2673 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -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