1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 12:14:43 +01:00

Add another test with long output

This commit is contained in:
Niklas Keller 2017-12-10 22:17:04 +01:00
parent 1a4cd84e82
commit d716404abc
2 changed files with 24 additions and 4 deletions

View File

@ -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());
});

View File

@ -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;
}