Skip to content

Commit 67df3be

Browse files
authored
Merge pull request #45 from seregazhuk/output-script-stderr
Output stderr of the underlying script
2 parents 5191941 + 0183da0 commit 67df3be

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/Screen.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public function subscribeToProcessOutput(Process $process): void
7575
$process->stdout->on('data', static function ($data) {
7676
echo $data;
7777
});
78+
$process->stderr->on('data', static function ($data) {
79+
echo $data;
80+
});
7881
}
7982

8083
public function showSpinner(LoopInterface $loop): void

tests/Helper/Filesystem.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ public static function createHelloWorldPHPFile(): string
2424
return $name;
2525
}
2626

27+
public static function createStdErrorPHPFile(): string
28+
{
29+
$name = self::FIXTURES_DIR . 'test.php';
30+
self::createFile($name, '<?php fwrite(STDERR, "Some error");');
31+
32+
return $name;
33+
}
34+
2735
public static function createHelloWorldPHPFileWithSignalsHandling(): string
2836
{
2937
$name = self::FIXTURES_DIR . 'test.php';

tests/RunScriptTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,16 @@ public function it_runs_a_php_script(): void
2020
$this->assertStringContainsString("starting `php $scriptToRun`", $output);
2121
$this->assertStringContainsString('Hello, world', $output);
2222
}
23+
24+
/** @test */
25+
public function it_outputs_the_script_stderr(): void
26+
{
27+
$scriptToRun = Filesystem::createStdErrorPHPFile();
28+
$watcher = (new WatcherRunner)->run($scriptToRun);
29+
30+
$this->wait();
31+
$output = $watcher->getOutput();
32+
33+
$this->assertStringContainsString('Some error', $output);
34+
}
2335
}

0 commit comments

Comments
 (0)