mirror of
https://github.com/danog/process.git
synced 2024-11-30 04:39:04 +01:00
Add another test with long output
This commit is contained in:
parent
1a4cd84e82
commit
d716404abc
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Amp\Process\Test;
|
namespace Amp\Process\Test;
|
||||||
|
|
||||||
|
use Amp\ByteStream\Message;
|
||||||
use Amp\Delayed;
|
use Amp\Delayed;
|
||||||
use Amp\Loop;
|
use Amp\Loop;
|
||||||
use Amp\Process\Process;
|
use Amp\Process\Process;
|
||||||
@ -313,8 +314,21 @@ class ProcessTest extends TestCase {
|
|||||||
$process = new Process(["php", __DIR__ . "/bin/worker.php"]);
|
$process = new Process(["php", __DIR__ . "/bin/worker.php"]);
|
||||||
$process->start();
|
$process->start();
|
||||||
|
|
||||||
$process->getStdin()->write("exit");
|
$process->getStdin()->write("exit 2");
|
||||||
$this->assertSame("ok", yield $process->getStdout()->read());
|
$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());
|
$this->assertSame(0, yield $process->join());
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,14 @@
|
|||||||
|
|
||||||
$content = fread(STDIN, 1024);
|
$content = fread(STDIN, 1024);
|
||||||
|
|
||||||
if ($content === "exit") {
|
$command = explode(" ", $content);
|
||||||
echo "ok";
|
|
||||||
|
if (count($command) !== 2) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($command[0] === "exit") {
|
||||||
|
echo str_repeat(".", (int) $command[1]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user