[Process] Fix process status in TTY mode

When running a process with TTY mode, status in automatically set to `terminated`
once it's started.

It's wrong for two reasons :
 - The status of the process is not yet terminated.
 - The exitcode value is never caught
This commit is contained in:
Romain Neutron 2014-03-10 17:14:59 +01:00
parent 1017d83260
commit 51c70f85dd
3 changed files with 24 additions and 3 deletions

View File

@ -248,8 +248,6 @@ class Process
$this->processPipes->unblock();
if ($this->tty) {
$this->status = self::STATUS_TERMINATED;
return;
}

View File

@ -223,11 +223,26 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$process = $this->getProcess('echo "foo" >> /dev/null');
$process->setTTY(true);
$process->run();
$process->start();
$this->assertTrue($process->isRunning());
$process->wait();
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
}
public function testTTYCommandExitCode()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Windows does have /dev/tty support');
}
$process = $this->getProcess('echo "foo" >> /dev/null');
$process->setTTY(true);
$process->run();
$this->assertTrue($process->isSuccessful());
}
public function testExitCodeText()
{
$process = $this->getProcess('');

View File

@ -144,6 +144,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
parent::testIsNotSuccessful();
}
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testTTYCommandExitCode()
{
parent::testTTYCommandExitCode();
}
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/