Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
144
vendor/symfony/process/Tests/ProcessTest.php
vendored
144
vendor/symfony/process/Tests/ProcessTest.php
vendored
@@ -28,7 +28,6 @@ class ProcessTest extends TestCase
|
||||
private static $phpBin;
|
||||
private static $process;
|
||||
private static $sigchild;
|
||||
private static $notEnhancedSigchild = false;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
@@ -49,19 +48,19 @@ class ProcessTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
* @expectedExceptionMessage The provided cwd does not exist.
|
||||
*/
|
||||
public function testInvalidCwd()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('False-positive on Windows/appveyor.');
|
||||
try {
|
||||
// Check that it works fine if the CWD exists
|
||||
$cmd = new Process('echo test', __DIR__);
|
||||
$cmd->run();
|
||||
} catch (\Exception $e) {
|
||||
$this->fail($e);
|
||||
}
|
||||
|
||||
// Check that it works fine if the CWD exists
|
||||
$cmd = new Process('echo test', __DIR__);
|
||||
$cmd->run();
|
||||
|
||||
$cmd = new Process('echo test', __DIR__.'/notfound/');
|
||||
$cmd->run();
|
||||
}
|
||||
@@ -118,9 +117,14 @@ class ProcessTest extends TestCase
|
||||
$p = $this->getProcess(array(self::$phpBin, __DIR__.'/NonStopableProcess.php', 30));
|
||||
$p->start();
|
||||
|
||||
while (false === strpos($p->getOutput(), 'received')) {
|
||||
while ($p->isRunning() && false === strpos($p->getOutput(), 'received')) {
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
if (!$p->isRunning()) {
|
||||
throw new \LogicException('Process is not running: '.$p->getErrorOutput());
|
||||
}
|
||||
|
||||
$start = microtime(true);
|
||||
$p->stop(0.1);
|
||||
|
||||
@@ -438,7 +442,6 @@ class ProcessTest extends TestCase
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX exit code');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
// such command run in bash return an exitcode 127
|
||||
$process = $this->getProcess('nonexistingcommandIhopeneversomeonewouldnameacommandlikethis');
|
||||
@@ -473,7 +476,6 @@ class ProcessTest extends TestCase
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does have /dev/tty support');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||
$process->setTty(true);
|
||||
@@ -499,8 +501,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testExitCodeTextIsNullWhenExitCodeIsNull()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('');
|
||||
$this->assertNull($process->getExitCodeText());
|
||||
}
|
||||
@@ -521,8 +521,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testMustRun()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo');
|
||||
|
||||
$this->assertSame($process, $process->mustRun());
|
||||
@@ -531,8 +529,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testSuccessfulMustRunHasCorrectExitCode()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo')->mustRun();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
@@ -542,16 +538,12 @@ class ProcessTest extends TestCase
|
||||
*/
|
||||
public function testMustRunThrowsException()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('exit 1');
|
||||
$process->mustRun();
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('');
|
||||
$r = new \ReflectionObject($process);
|
||||
$p = $r->getProperty('exitcode');
|
||||
@@ -580,8 +572,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testGetExitCodeIsNullOnStart()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcessForCode('usleep(100000);');
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->start();
|
||||
@@ -592,8 +582,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcessForCode('usleep(100000);');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
@@ -605,8 +593,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testGetExitCode()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertSame(0, $process->getExitCode());
|
||||
@@ -642,8 +628,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
@@ -651,8 +635,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testIsSuccessfulOnlyAfterTerminated()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcessForCode('usleep(100000);');
|
||||
$process->start();
|
||||
|
||||
@@ -665,8 +647,6 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcessForCode('throw new \Exception(\'BOUM\');');
|
||||
$process->run();
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
@@ -677,7 +657,6 @@ class ProcessTest extends TestCase
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
@@ -689,7 +668,6 @@ class ProcessTest extends TestCase
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
@@ -701,7 +679,6 @@ class ProcessTest extends TestCase
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcessForCode('sleep(32);');
|
||||
$process->start();
|
||||
@@ -711,15 +688,18 @@ class ProcessTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
* @expectedExceptionMessage The process has been signaled
|
||||
* @expectedException \Symfony\Component\Process\Exception\ProcessSignaledException
|
||||
* @expectedExceptionMessage The process has been signaled with signal "9".
|
||||
*/
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
if (!\function_exists('posix_kill')) {
|
||||
$this->markTestSkipped('Function posix_kill is required.');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild(false);
|
||||
|
||||
if (self::$sigchild) {
|
||||
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
|
||||
}
|
||||
|
||||
$process = $this->getProcessForCode('sleep(32.1);');
|
||||
$process->start();
|
||||
@@ -930,8 +910,6 @@ class ProcessTest extends TestCase
|
||||
*/
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess('sleep 4');
|
||||
$process->start();
|
||||
$process->signal(SIGKILL);
|
||||
@@ -1015,10 +993,9 @@ class ProcessTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideWrongSignal
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testWrongSignal($signal)
|
||||
public function testWrongSignal()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
@@ -1027,7 +1004,7 @@ class ProcessTest extends TestCase
|
||||
$process = $this->getProcessForCode('sleep(38);');
|
||||
$process->start();
|
||||
try {
|
||||
$process->signal($signal);
|
||||
$process->signal(-4);
|
||||
$this->fail('A RuntimeException must have been thrown');
|
||||
} catch (RuntimeException $e) {
|
||||
$process->stop(0);
|
||||
@@ -1036,14 +1013,6 @@ class ProcessTest extends TestCase
|
||||
throw $e;
|
||||
}
|
||||
|
||||
public function provideWrongSignal()
|
||||
{
|
||||
return array(
|
||||
array(-4),
|
||||
array('Céphalopodes'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testDisableOutputDisablesTheOutput()
|
||||
{
|
||||
$p = $this->getProcess('foo');
|
||||
@@ -1457,31 +1426,6 @@ class ProcessTest extends TestCase
|
||||
unset($_ENV['FOO']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testInheritEnvDisabled()
|
||||
{
|
||||
$process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ'));
|
||||
|
||||
putenv('FOO=BAR');
|
||||
$_ENV['FOO'] = 'BAR';
|
||||
|
||||
$this->assertSame($process, $process->inheritEnvironmentVariables(false));
|
||||
$this->assertFalse($process->areEnvironmentVariablesInherited());
|
||||
|
||||
$process->run();
|
||||
|
||||
$expected = array('BAR' => 'BAZ', 'FOO' => 'BAR');
|
||||
$env = array_intersect_key(unserialize($process->getOutput()), $expected);
|
||||
unset($expected['FOO']);
|
||||
|
||||
$this->assertSame($expected, $env);
|
||||
|
||||
putenv('FOO');
|
||||
unset($_ENV['FOO']);
|
||||
}
|
||||
|
||||
public function testGetCommandLine()
|
||||
{
|
||||
$p = new Process(array('/usr/bin/php'));
|
||||
@@ -1501,19 +1445,6 @@ class ProcessTest extends TestCase
|
||||
$this->assertSame($arg, $p->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideEscapeArgument
|
||||
* @group legacy
|
||||
*/
|
||||
public function testEscapeArgumentWhenInheritEnvDisabled($arg)
|
||||
{
|
||||
$p = new Process(array(self::$phpBin, '-r', 'echo $argv[1];', $arg), null, array('BAR' => 'BAZ'));
|
||||
$p->inheritEnvironmentVariables(false);
|
||||
$p->run();
|
||||
|
||||
$this->assertSame($arg, $p->getOutput());
|
||||
}
|
||||
|
||||
public function testRawCommandLine()
|
||||
{
|
||||
$p = new Process(sprintf('"%s" -r %s "a" "" "b"', self::$phpBin, escapeshellarg('print_r($argv);')));
|
||||
@@ -1569,21 +1500,6 @@ EOTXT;
|
||||
$process = new Process($commandline, $cwd, $env, $input, $timeout);
|
||||
$process->inheritEnvironmentVariables();
|
||||
|
||||
if (false !== $enhance = getenv('ENHANCE_SIGCHLD')) {
|
||||
try {
|
||||
$process->setEnhanceSigchildCompatibility(false);
|
||||
$process->getExitCode();
|
||||
$this->fail('ENHANCE_SIGCHLD must be used together with a sigchild-enabled PHP.');
|
||||
} catch (RuntimeException $e) {
|
||||
$this->assertSame('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.', $e->getMessage());
|
||||
if ($enhance) {
|
||||
$process->setEnhanceSigchildCompatibility(true);
|
||||
} else {
|
||||
self::$notEnhancedSigchild = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$process) {
|
||||
self::$process->stop(0);
|
||||
}
|
||||
@@ -1598,22 +1514,6 @@ EOTXT;
|
||||
{
|
||||
return $this->getProcess(array(self::$phpBin, '-r', $code), $cwd, $env, $input, $timeout);
|
||||
}
|
||||
|
||||
private function skipIfNotEnhancedSigchild($expectException = true)
|
||||
{
|
||||
if (self::$sigchild) {
|
||||
if (!$expectException) {
|
||||
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
|
||||
} elseif (self::$notEnhancedSigchild) {
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
|
||||
$this->expectExceptionMessage('This PHP has been compiled with --enable-sigchild.');
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NonStringifiable
|
||||
|
Reference in New Issue
Block a user