diff --git a/test/ProcessTest.php b/test/ProcessTest.php index 85495f9..0d5b8c4 100644 --- a/test/ProcessTest.php +++ b/test/ProcessTest.php @@ -2,6 +2,7 @@ namespace Amp\Process\Test; +use Amp\ByteStream\Message; use Amp\Delayed; use Amp\Loop; use Amp\Process\Process; @@ -313,8 +314,21 @@ class ProcessTest extends TestCase { $process = new Process(["php", __DIR__ . "/bin/worker.php"]); $process->start(); - $process->getStdin()->write("exit"); - $this->assertSame("ok", yield $process->getStdout()->read()); + $process->getStdin()->write("exit 2"); + $this->assertSame("..", yield $process->getStdout()->read()); + + $this->assertSame(0, yield $process->join()); + }); + } + + public function testReadOutputAfterExitWithLongOutput() { + Loop::run(function () { + $process = new Process(["php", __DIR__ . "/bin/worker.php"]); + $process->start(); + + $count = 128 * 1024 + 1; + $process->getStdin()->write("exit " . $count); + $this->assertSame(str_repeat(".", $count), yield new Message($process->getStdout())); $this->assertSame(0, yield $process->join()); }); diff --git a/test/bin/worker.php b/test/bin/worker.php index 9fc6f4d..d2ffb7f 100644 --- a/test/bin/worker.php +++ b/test/bin/worker.php @@ -2,8 +2,14 @@ $content = fread(STDIN, 1024); -if ($content === "exit") { - echo "ok"; +$command = explode(" ", $content); + +if (count($command) !== 2) { + exit(1); +} + +if ($command[0] === "exit") { + echo str_repeat(".", (int) $command[1]); exit; }