merged branch stloyd/bugfix/process_tests (PR #7947)
This PR was merged into the 2.1 branch.
Discussion
----------
[Process] Cleanup tests & prevent assertion that kills randomly Travis-CI
Commits
-------
05b987f
[Process] Cleanup tests & prevent assertion that kills randomly Travis-CI
This commit is contained in:
commit
de98954016
@ -88,18 +88,21 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @dataProvider pipesCodeProvider
|
* @dataProvider pipesCodeProvider
|
||||||
*/
|
*/
|
||||||
public function testProcessPipes($expected, $code)
|
public function testProcessPipes($code, $size)
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
|
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$expected = str_repeat(str_repeat('*', 1024), $size) . '!';
|
||||||
|
$expectedLength = (1024 * $size) + 1;
|
||||||
|
|
||||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
||||||
$p->setStdin($expected);
|
$p->setStdin($expected);
|
||||||
$p->run();
|
$p->run();
|
||||||
|
|
||||||
$this->assertSame($expected, $p->getOutput());
|
$this->assertEquals($expectedLength, strlen($p->getOutput()));
|
||||||
$this->assertSame($expected, $p->getErrorOutput());
|
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function chainedCommandsOutputProvider()
|
public function chainedCommandsOutputProvider()
|
||||||
@ -338,13 +341,11 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
|
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
|
||||||
'include \'' . __DIR__ . '/ProcessTestHelper.php\';',
|
'include \'' . __DIR__ . '/ProcessTestHelper.php\';',
|
||||||
);
|
);
|
||||||
$baseData = str_repeat('*', 1024);
|
|
||||||
|
|
||||||
$codes = array();
|
$codes = array();
|
||||||
foreach (array(1, 16, 64, 1024, 4096) as $size) {
|
foreach (array(1, 16, 64, 1024, 4096) as $size) {
|
||||||
$data = str_repeat($baseData, $size) . '!';
|
|
||||||
foreach ($variations as $code) {
|
foreach ($variations as $code) {
|
||||||
$codes[] = array($data, $code);
|
$codes[] = array($code, $size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ use Symfony\Component\Process\PhpProcess;
|
|||||||
|
|
||||||
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testNonBlockingWorks()
|
public function testNonBlockingWorks()
|
||||||
{
|
{
|
||||||
$expected = 'hello world!';
|
$expected = 'hello world!';
|
||||||
|
@ -15,10 +15,7 @@ use Symfony\Component\Process\ProcessBuilder;
|
|||||||
|
|
||||||
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
public function testInheritEnvironmentVars()
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldInheritEnvironmentVars()
|
|
||||||
{
|
{
|
||||||
$snapshot = $_ENV;
|
$snapshot = $_ENV;
|
||||||
$_ENV = $expected = array('foo' => 'bar');
|
$_ENV = $expected = array('foo' => 'bar');
|
||||||
@ -32,10 +29,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_ENV = $snapshot;
|
$_ENV = $snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testProcessShouldInheritAndOverrideEnvironmentVars()
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldInheritAndOverrideEnvironmentVars()
|
|
||||||
{
|
{
|
||||||
$snapshot = $_ENV;
|
$snapshot = $_ENV;
|
||||||
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
|
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
|
||||||
@ -51,10 +45,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_ENV = $snapshot;
|
$_ENV = $snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testInheritEnvironmentVarsByDefault()
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldInheritEnvironmentVarsByDefault()
|
|
||||||
{
|
{
|
||||||
$pb = new ProcessBuilder();
|
$pb = new ProcessBuilder();
|
||||||
$proc = $pb->add('foo')->getProcess();
|
$proc = $pb->add('foo')->getProcess();
|
||||||
@ -62,10 +53,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($proc->getEnv());
|
$this->assertNull($proc->getEnv());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testNotReplaceExplicitlySetVars()
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldNotReplaceExplicitlySetVars()
|
|
||||||
{
|
{
|
||||||
$snapshot = $_ENV;
|
$snapshot = $_ENV;
|
||||||
$_ENV = array('foo' => 'bar');
|
$_ENV = array('foo' => 'bar');
|
||||||
|
@ -37,7 +37,8 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
|
|||||||
'\InvalidArgumentException',
|
'\InvalidArgumentException',
|
||||||
'Expected a failed process, but the given process was successful.'
|
'Expected a failed process, but the given process was successful.'
|
||||||
);
|
);
|
||||||
$exception = new ProcessFailedException($process);
|
|
||||||
|
new ProcessFailedException($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Process\Tests;
|
|||||||
class SigchildDisabledProcessTest extends AbstractProcessTest
|
class SigchildDisabledProcessTest extends AbstractProcessTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testGetExitCode()
|
public function testGetExitCode()
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testExitCodeCommandFailed()
|
public function testExitCodeCommandFailed()
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessIsSignaledIfStopped()
|
public function testProcessIsSignaledIfStopped()
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessWithTermSignal()
|
public function testProcessWithTermSignal()
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessIsNotSignaled()
|
public function testProcessIsNotSignaled()
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignal()
|
public function testProcessWithoutTermSignal()
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testExitCodeText()
|
public function testExitCodeText()
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testIsSuccessful()
|
public function testIsSuccessful()
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testIsNotSuccessful()
|
public function testIsNotSuccessful()
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Process\Tests;
|
|||||||
class SigchildEnabledProcessTest extends AbstractProcessTest
|
class SigchildEnabledProcessTest extends AbstractProcessTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessIsSignaledIfStopped()
|
public function testProcessIsSignaledIfStopped()
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessWithTermSignal()
|
public function testProcessWithTermSignal()
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessIsNotSignaled()
|
public function testProcessIsNotSignaled()
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProcessWithoutTermSignal()
|
public function testProcessWithoutTermSignal()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user