Skip to content

Commit

Permalink
[Process] Disable TTY mode on Windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Apr 24, 2014
1 parent 6518b74 commit 7942c2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -774,9 +774,15 @@ public function setTimeout($timeout)
* @param bool $tty True to enabled and false to disable
*
* @return self The current Process instance
*
* @throws RuntimeException In case the TTY mode is not supported
*/
public function setTty($tty)
{
if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) {
throw new RuntimeException('TTY mode is not supported on Windows platform.');
}

$this->tty = (bool) $tty;

return $this;
Expand Down
16 changes: 14 additions & 2 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Expand Up @@ -251,7 +251,7 @@ public function testTTYCommand()
}

$process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"');
$process->setTTY(true);
$process->setTty(true);
$process->start();
$this->assertTrue($process->isRunning());
$process->wait();
Expand All @@ -266,12 +266,24 @@ public function testTTYCommandExitCode()
}

$process = $this->getProcess('echo "foo" >> /dev/null');
$process->setTTY(true);
$process->setTty(true);
$process->run();

$this->assertTrue($process->isSuccessful());
}

public function testTTYInWindowsEnvironment()
{
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('This test is for Windows platform only');
}

$process = $this->getProcess('echo "foo" >> /dev/null');
$process->setTty(false);
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'TTY mode is not supported on Windows platform.');
$process->setTty(true);
}

public function testExitCodeTextIsNullWhenExitCodeIsNull()
{
$process = $this->getProcess('');
Expand Down

0 comments on commit 7942c2a

Please sign in to comment.