Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eed17e9

Browse files
Merge branch '3.0'
* 3.0: [Process] Clean tested process on tear down
2 parents 9c2dbb6 + e469ef4 commit eed17e9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
class ProcessTest extends \PHPUnit_Framework_TestCase
2525
{
2626
private static $phpBin;
27+
private static $process;
2728
private static $sigchild;
2829
private static $notEnhancedSigchild = false;
2930

@@ -43,6 +44,14 @@ public static function setUpBeforeClass()
4344
self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
4445
}
4546

47+
protected function tearDown()
48+
{
49+
if (self::$process) {
50+
self::$process->stop(0);
51+
self::$process = null;
52+
}
53+
}
54+
4655
public function testThatProcessDoesNotThrowWarningDuringRun()
4756
{
4857
@trigger_error('Test Error', E_USER_NOTICE);
@@ -123,9 +132,9 @@ public function testAllOutputIsActuallyReadOnTermination()
123132
$h = new \ReflectionProperty($p, 'process');
124133
$h->setAccessible(true);
125134
$h = $h->getValue($p);
126-
$s = proc_get_status($h);
135+
$s = @proc_get_status($h);
127136

128-
while ($s['running']) {
137+
while (!empty($s['running'])) {
129138
usleep(1000);
130139
$s = proc_get_status($h);
131140
}
@@ -1259,7 +1268,11 @@ private function getProcess($commandline, $cwd = null, array $env = null, $input
12591268
}
12601269
}
12611270

1262-
return $process;
1271+
if (self::$process) {
1272+
self::$process->stop(0);
1273+
}
1274+
1275+
return self::$process = $process;
12631276
}
12641277

12651278
private function skipIfNotEnhancedSigchild($expectException = true)

0 commit comments

Comments
 (0)