Skip to content

Commit 6c11207

Browse files
committed
attempts to fix tests on Travis
1 parent 2ff1870 commit 6c11207

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ class Process
120120
159 => 'Bad syscall',
121121
);
122122

123+
/**
124+
* Returns whether PTY is supported on the current operating system.
125+
*
126+
* @return Boolean
127+
*/
128+
public static function isPtySupported()
129+
{
130+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
131+
return false;
132+
}
133+
134+
$proc = @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
135+
if (is_resource($proc)) {
136+
proc_close($proc);
137+
138+
return true;
139+
}
140+
141+
return false;
142+
}
143+
123144
/**
124145
* Constructor.
125146
*
@@ -1183,7 +1204,7 @@ private function getDescriptors()
11831204
array('file', '/dev/tty', 'w'),
11841205
array('file', '/dev/tty', 'w'),
11851206
);
1186-
} elseif ($this->pty) {
1207+
} elseif ($this->pty && self::isPtySupported()) {
11871208
$descriptors = array(
11881209
array('pty'),
11891210
array('pty'),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ public function testTTYCommand()
205205
*/
206206
public function testPTYCommand()
207207
{
208-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
209-
$this->markTestSkipped('Windows does not have PTY support.');
208+
if ( ! Process::isPtySupported()) {
209+
$this->markTestSkipped('PTY is not supported on this operating system.');
210210
}
211211

212212
$process = $this->getProcess('echo "foo"');

0 commit comments

Comments
 (0)