diff --git a/incubation/test_process/lib/src/invoked_process.dart b/incubation/test_process/lib/src/invoked_process.dart index a36e49b..6546f35 100644 --- a/incubation/test_process/lib/src/invoked_process.dart +++ b/incubation/test_process/lib/src/invoked_process.dart @@ -67,6 +67,11 @@ class InvokedProcess { } } + /// Close the process stdin. + Future closeStdin() async { + await _process.stdin.close(); + } + /// Signal the process. bool kill([ProcessSignal signal = ProcessSignal.sigterm]) { _killed = true; diff --git a/incubation/test_process/test/invoked_process_test.dart b/incubation/test_process/test/invoked_process_test.dart index b4f31f1..d1bacc2 100644 --- a/incubation/test_process/test/invoked_process_test.dart +++ b/incubation/test_process/test/invoked_process_test.dart @@ -50,7 +50,7 @@ void main() { process.write('Hello'); process.write(' World'); - await process.kill(); // Force process to complete + await process.closeStdin(); final result = await process.wait(); expect(result.output().trim(), equals('Hello World')); }, timeout: Timeout(Duration(seconds: 5))); @@ -60,7 +60,7 @@ void main() { final process = await factory.command(['cat']).start(); process.write([72, 101, 108, 108, 111]); // "Hello" in bytes - await process.kill(); // Force process to complete + await process.closeStdin(); final result = await process.wait(); expect(result.output().trim(), equals('Hello')); }, timeout: Timeout(Duration(seconds: 5)));