mirror of
https://github.com/danog/process.git
synced 2024-11-30 04:39:04 +01:00
parent
d2d8d79615
commit
5f5a901744
@ -269,4 +269,16 @@ class Process
|
||||
|
||||
return $this->handle->stderr;
|
||||
}
|
||||
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
return [
|
||||
'command' => $this->getCommand(),
|
||||
'cwd' => $this->getWorkingDirectory(),
|
||||
'env' => $this->getEnv(),
|
||||
'options' => $this->getOptions(),
|
||||
'pid' => $this->pid,
|
||||
'status' => $this->handle ? $this->handle->status : -1,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace Amp\Process\Test;
|
||||
use Amp\ByteStream\Message;
|
||||
use Amp\Delayed;
|
||||
use Amp\Loop;
|
||||
use Amp\Process\Internal\ProcessStatus;
|
||||
use Amp\Process\Process;
|
||||
use Amp\Process\ProcessInputStream;
|
||||
use Amp\Process\ProcessOutputStream;
|
||||
@ -358,4 +359,26 @@ class ProcessTest extends TestCase
|
||||
$this->assertSame(0, yield $process->join());
|
||||
});
|
||||
}
|
||||
|
||||
public function testDebugInfo() {
|
||||
Loop::run(function () {
|
||||
$process = new Process(["php", __DIR__ . "/bin/worker.php"], __DIR__);
|
||||
|
||||
$this->assertSame([
|
||||
'command' => "'php' '" . __DIR__ . "/bin/worker.php'",
|
||||
'cwd' => __DIR__,
|
||||
'env' => [],
|
||||
'options' => [],
|
||||
'pid' => null,
|
||||
'status' => -1,
|
||||
], $process->__debugInfo());
|
||||
|
||||
yield $process->start();
|
||||
|
||||
$debug = $process->__debugInfo();
|
||||
|
||||
$this->assertInternalType('int', $debug['pid']);
|
||||
$this->assertSame(ProcessStatus::RUNNING, $debug['status']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user