From 1b9d32cd58db44c9b4807d96875c1fed060e9b89 Mon Sep 17 00:00:00 2001 From: Zhuk Sergey Date: Mon, 28 Oct 2019 01:11:49 +0300 Subject: [PATCH] Output stderr of the underlying script --- src/Screen/Screen.php | 3 +++ tests/Helper/Filesystem.php | 8 ++++++++ tests/RunScriptTest.php | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/Screen/Screen.php b/src/Screen/Screen.php index 5e26b29..4b65aeb 100644 --- a/src/Screen/Screen.php +++ b/src/Screen/Screen.php @@ -75,6 +75,9 @@ public function subscribeToProcessOutput(Process $process): void $process->stdout->on('data', static function ($data) { echo $data; }); + $process->stderr->on('data', static function ($data) { + echo $data; + }); } public function showSpinner(LoopInterface $loop): void diff --git a/tests/Helper/Filesystem.php b/tests/Helper/Filesystem.php index 56fa540..03324b4 100644 --- a/tests/Helper/Filesystem.php +++ b/tests/Helper/Filesystem.php @@ -24,6 +24,14 @@ public static function createHelloWorldPHPFile(): string return $name; } + public static function createStdErrorPHPFile(): string + { + $name = self::FIXTURES_DIR . 'test.php'; + self::createFile($name, 'assertStringContainsString("starting `php $scriptToRun`", $output); $this->assertStringContainsString('Hello, world', $output); } + + /** @test */ + public function it_outputs_the_script_stderr(): void + { + $scriptToRun = Filesystem::createStdErrorPHPFile(); + $watcher = (new WatcherRunner)->run($scriptToRun); + + $this->wait(); + $output = $watcher->getOutput(); + + $this->assertStringContainsString('Some error', $output); + } }