Skip to content

Commit 7942c2a

Browse files
committed
[Process] Disable TTY mode on Windows platform
1 parent 6518b74 commit 7942c2a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Symfony/Component/Process/Process.php

+6
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,15 @@ public function setTimeout($timeout)
774774
* @param bool $tty True to enabled and false to disable
775775
*
776776
* @return self The current Process instance
777+
*
778+
* @throws RuntimeException In case the TTY mode is not supported
777779
*/
778780
public function setTty($tty)
779781
{
782+
if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) {
783+
throw new RuntimeException('TTY mode is not supported on Windows platform.');
784+
}
785+
780786
$this->tty = (bool) $tty;
781787

782788
return $this;

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function testTTYCommand()
251251
}
252252

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

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

272272
$this->assertTrue($process->isSuccessful());
273273
}
274274

275+
public function testTTYInWindowsEnvironment()
276+
{
277+
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
278+
$this->markTestSkipped('This test is for Windows platform only');
279+
}
280+
281+
$process = $this->getProcess('echo "foo" >> /dev/null');
282+
$process->setTty(false);
283+
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'TTY mode is not supported on Windows platform.');
284+
$process->setTty(true);
285+
}
286+
275287
public function testExitCodeTextIsNullWhenExitCodeIsNull()
276288
{
277289
$process = $this->getProcess('');

0 commit comments

Comments
 (0)