Skip to content
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
3 changes: 3 additions & 0 deletions src/Screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/Helper/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<?php fwrite(STDERR, "Some error");');

return $name;
}

public static function createHelloWorldPHPFileWithSignalsHandling(): string
{
$name = self::FIXTURES_DIR . 'test.php';
Expand Down
12 changes: 12 additions & 0 deletions tests/RunScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,16 @@ public function it_runs_a_php_script(): void
$this->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);
}
}