the whole shebang
This commit is contained in:
641
vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php
vendored
Normal file
641
vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php
vendored
Normal file
@@ -0,0 +1,641 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
*/
|
||||
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromConstructor()
|
||||
{
|
||||
$this->getProcess('', null, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromSetter()
|
||||
{
|
||||
$p = $this->getProcess('');
|
||||
$p->setTimeout(-1);
|
||||
}
|
||||
|
||||
public function testNullTimeout()
|
||||
{
|
||||
$p = $this->getProcess('');
|
||||
$p->setTimeout(10);
|
||||
$p->setTimeout(null);
|
||||
|
||||
$this->assertNull($p->getTimeout());
|
||||
}
|
||||
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
// exec is mandatory here since we send a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
$p = $this->getProcess('exec php '.__DIR__.'/NonStopableProcess.php 3');
|
||||
$p->start();
|
||||
usleep(100000);
|
||||
$start = microtime(true);
|
||||
$p->stop(1.1, SIGKILL);
|
||||
while ($p->isRunning()) {
|
||||
usleep(1000);
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan(1.8, $duration);
|
||||
}
|
||||
|
||||
public function testCallbacksAreExecutedWithStart()
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$process = $this->getProcess('echo "foo";sleep 1;echo "foo"');
|
||||
$process->start(function ($type, $buffer) use (&$data) {
|
||||
$data .= $buffer;
|
||||
});
|
||||
|
||||
$start = microtime(true);
|
||||
while ($process->isRunning()) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertEquals("foo\nfoo\n", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests results from sub processes
|
||||
*
|
||||
* @dataProvider responsesCodeProvider
|
||||
*/
|
||||
public function testProcessResponses($expected, $getter, $code)
|
||||
{
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
||||
$p->run();
|
||||
|
||||
$this->assertSame($expected, $p->$getter());
|
||||
}
|
||||
|
||||
/**
|
||||
* tests results from sub processes
|
||||
*
|
||||
* @dataProvider pipesCodeProvider
|
||||
*/
|
||||
public function testProcessPipes($code, $size)
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
$expected = str_repeat(str_repeat('*', 1024), $size) . '!';
|
||||
$expectedLength = (1024 * $size) + 1;
|
||||
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
||||
$p->setStdin($expected);
|
||||
$p->run();
|
||||
|
||||
$this->assertEquals($expectedLength, strlen($p->getOutput()));
|
||||
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
|
||||
}
|
||||
|
||||
public function chainedCommandsOutputProvider()
|
||||
{
|
||||
return array(
|
||||
array("1\n1\n", ';', '1'),
|
||||
array("2\n2\n", '&&', '2'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider chainedCommandsOutputProvider
|
||||
*/
|
||||
public function testChainedCommandsOutput($expected, $operator, $input)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Does it work on windows ?');
|
||||
}
|
||||
|
||||
$process = $this->getProcess(sprintf('echo %s %s echo %s', $input, $operator, $input));
|
||||
$process->run();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
|
||||
public function testCallbackIsExecutedForOutput()
|
||||
{
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('echo \'foo\';')));
|
||||
|
||||
$called = false;
|
||||
$p->run(function ($type, $buffer) use (&$called) {
|
||||
$called = $buffer === 'foo';
|
||||
});
|
||||
|
||||
$this->assertTrue($called, 'The callback should be executed with the output');
|
||||
}
|
||||
|
||||
public function testGetErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->run();
|
||||
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
|
||||
}
|
||||
|
||||
public function testGetIncrementalErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->start();
|
||||
while ($p->isRunning()) {
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}')));
|
||||
|
||||
$p->run();
|
||||
$this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches));
|
||||
}
|
||||
|
||||
public function testGetIncrementalOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) { echo \' foo \'; usleep(50000); $n++; }')));
|
||||
|
||||
$p->start();
|
||||
while ($p->isRunning()) {
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches));
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX exit code');
|
||||
}
|
||||
|
||||
// such command run in bash return an exitcode 127
|
||||
$process = $this->getProcess('nonexistingcommandIhopeneversomeonewouldnameacommandlikethis');
|
||||
$process->run();
|
||||
|
||||
$this->assertGreaterThan(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testTTYCommand()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does have /dev/tty support');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||
$process->setTTY(true);
|
||||
$process->run();
|
||||
|
||||
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('');
|
||||
$r = new \ReflectionObject($process);
|
||||
$p = $r->getProperty('exitcode');
|
||||
$p->setAccessible(true);
|
||||
|
||||
$p->setValue($process, 2);
|
||||
$this->assertEquals('Misuse of shell builtins', $process->getExitCodeText());
|
||||
}
|
||||
|
||||
public function testStartIsNonBlocking()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$start = microtime(true);
|
||||
$process->start();
|
||||
$end = microtime(true);
|
||||
$this->assertLessThan(1 , $end-$start);
|
||||
}
|
||||
|
||||
public function testUpdateStatus()
|
||||
{
|
||||
$process = $this->getProcess('php -h');
|
||||
$process->run();
|
||||
$this->assertTrue(strlen($process->getOutput()) > 0);
|
||||
}
|
||||
|
||||
public function testGetExitCodeIsNullOnStart()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(200000);"');
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->start();
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->wait();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(200000);"');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
$process->start();
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->wait();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testGetExitCode()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testStatus()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(500000);"');
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertFalse($process->isStarted());
|
||||
$this->assertFalse($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_READY, $process->getStatus());
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$this->assertTrue($process->isStarted());
|
||||
$this->assertFalse($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_STARTED, $process->getStatus());
|
||||
$process->wait();
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertTrue($process->isStarted());
|
||||
$this->assertTrue($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
||||
}
|
||||
|
||||
public function testStop()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop();
|
||||
$this->assertFalse($process->isRunning());
|
||||
}
|
||||
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testIsSuccessfulOnlyAfterTerminated()
|
||||
{
|
||||
$process = $this->getProcess('sleep 1');
|
||||
$process->start();
|
||||
while ($process->isRunning()) {
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
usleep(300000);
|
||||
}
|
||||
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop();
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getTermSignal());
|
||||
}
|
||||
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
$this->assertTrue($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
// SIGTERM is only defined if pcntl extension is present
|
||||
$termSignal = defined('SIGTERM') ? SIGTERM : 15;
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
|
||||
$this->assertEquals($termSignal, $process->getTermSignal());
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
if (!function_exists('posix_kill')) {
|
||||
$this->markTestSkipped('posix_kill is required for this test');
|
||||
}
|
||||
|
||||
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
||||
|
||||
$process = $this->getProcess('exec php -r "while (true) {}"');
|
||||
$process->start();
|
||||
posix_kill($process->getPid(), $termSignal);
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'The process has been signaled with signal "9".');
|
||||
$process->wait();
|
||||
}
|
||||
|
||||
public function testRestart()
|
||||
{
|
||||
$process1 = $this->getProcess('php -r "echo getmypid();"');
|
||||
$process1->run();
|
||||
$process2 = $process1->restart();
|
||||
|
||||
usleep(300000); // wait for output
|
||||
|
||||
// Ensure that both processed finished and the output is numeric
|
||||
$this->assertFalse($process1->isRunning());
|
||||
$this->assertFalse($process2->isRunning());
|
||||
$this->assertTrue(is_numeric($process1->getOutput()));
|
||||
$this->assertTrue(is_numeric($process2->getOutput()));
|
||||
|
||||
// Ensure that restart returned a new process by check that the output is different
|
||||
$this->assertNotEquals($process1->getOutput(), $process2->getOutput());
|
||||
}
|
||||
|
||||
public function testPhpDeadlock()
|
||||
{
|
||||
$this->markTestSkipped('Can course php to hang');
|
||||
|
||||
// Sleep doesn't work as it will allow the process to handle signals and close
|
||||
// file handles from the other end.
|
||||
$process = $this->getProcess('php -r "while (true) {}"');
|
||||
$process->start();
|
||||
|
||||
// PHP will deadlock when it tries to cleanup $process
|
||||
}
|
||||
|
||||
public function testRunProcessWithTimeout()
|
||||
{
|
||||
$timeout = 0.5;
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process->setTimeout($timeout);
|
||||
$start = microtime(true);
|
||||
try {
|
||||
$process->run();
|
||||
$this->fail('A RuntimeException should have been raised');
|
||||
} catch (RuntimeException $e) {
|
||||
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration);
|
||||
}
|
||||
|
||||
public function testCheckTimeoutOnStartedProcess()
|
||||
{
|
||||
$timeout = 0.5;
|
||||
$precision = 100000;
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process->setTimeout($timeout);
|
||||
$start = microtime(true);
|
||||
|
||||
$process->start();
|
||||
|
||||
try {
|
||||
while ($process->isRunning()) {
|
||||
$process->checkTimeout();
|
||||
usleep($precision);
|
||||
}
|
||||
$this->fail('A RuntimeException should have been raised');
|
||||
} catch (RuntimeException $e) {
|
||||
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan($timeout + $precision, $duration);
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testGetPid()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(1);"');
|
||||
$process->start();
|
||||
$this->assertGreaterThan(0, $process->getPid());
|
||||
$process->stop();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(1);"');
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
public function testSignal()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
$process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php');
|
||||
$process->start();
|
||||
usleep(500000);
|
||||
$process->signal(SIGUSR1);
|
||||
|
||||
while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
$process = $this->getProcess('sleep 4');
|
||||
$process->start();
|
||||
$process->signal(SIGKILL);
|
||||
|
||||
while ($process->isRunning()) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertTrue($process->hasBeenSignaled());
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
$this->assertEquals(137, $process->getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->signal(SIGHUP);
|
||||
}
|
||||
|
||||
private function verifyPosixIsEnabled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
if (!defined('SIGUSR1')) {
|
||||
$this->markTestSkipped('The pcntl extension is not enabled');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal(-4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal('Céphalopodes');
|
||||
}
|
||||
|
||||
public function responsesCodeProvider()
|
||||
{
|
||||
return array(
|
||||
//expected output / getter / code to execute
|
||||
//array(1,'getExitCode','exit(1);'),
|
||||
//array(true,'isSuccessful','exit();'),
|
||||
array('output', 'getOutput', 'echo \'output\';'),
|
||||
);
|
||||
}
|
||||
|
||||
public function pipesCodeProvider()
|
||||
{
|
||||
$variations = array(
|
||||
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
|
||||
'include \''.__DIR__.'/ProcessTestHelper.php\';',
|
||||
);
|
||||
|
||||
$codes = array();
|
||||
foreach (array(1, 16, 64, 1024, 4096) as $size) {
|
||||
foreach ($variations as $code) {
|
||||
$codes[] = array($code, $size);
|
||||
}
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* provides default method names for simple getter/setter
|
||||
*/
|
||||
public function methodProvider()
|
||||
{
|
||||
$defaults = array(
|
||||
array('CommandLine'),
|
||||
array('Timeout'),
|
||||
array('WorkingDirectory'),
|
||||
array('Env'),
|
||||
array('Stdin'),
|
||||
array('Options')
|
||||
);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $commandline
|
||||
* @param null $cwd
|
||||
* @param array $env
|
||||
* @param null $stdin
|
||||
* @param integer $timeout
|
||||
* @param array $options
|
||||
*
|
||||
* @return Process
|
||||
*/
|
||||
abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
|
||||
}
|
37
vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php
vendored
Normal file
37
vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds
|
||||
*
|
||||
* @args duration Run this script with a custom duration
|
||||
*
|
||||
* @example `php NonStopableProcess.php 42` will run the script for 42 seconds
|
||||
*/
|
||||
|
||||
function handleSignal($signal)
|
||||
{
|
||||
switch ($signal) {
|
||||
case SIGTERM:
|
||||
$name = 'SIGTERM';
|
||||
break;
|
||||
case SIGINT:
|
||||
$name = 'SIGINT';
|
||||
break;
|
||||
default:
|
||||
$name = $signal . ' (unknown)';
|
||||
break;
|
||||
}
|
||||
|
||||
echo "received signal $name\n";
|
||||
}
|
||||
|
||||
declare(ticks=1);
|
||||
pcntl_signal(SIGTERM, 'handleSignal');
|
||||
pcntl_signal(SIGINT, 'handleSignal');
|
||||
|
||||
$duration = isset($argv[1]) ? (int) $argv[1] : 3;
|
||||
$start = microtime(true);
|
||||
|
||||
while ($duration > (microtime(true) - $start)) {
|
||||
usleep(1000);
|
||||
}
|
64
vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
64
vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
*/
|
||||
class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* tests find() with the env var PHP_PATH
|
||||
*/
|
||||
public function testFindWithPhpPath()
|
||||
{
|
||||
if (defined('PHP_BINARY')) {
|
||||
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
|
||||
}
|
||||
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
$current = $f->find();
|
||||
|
||||
//not executable PHP_PATH
|
||||
putenv('PHP_PATH=/not/executable/php');
|
||||
$this->assertFalse($f->find(), '::find() returns false for not executable php');
|
||||
|
||||
//executable PHP_PATH
|
||||
putenv('PHP_PATH='.$current);
|
||||
$this->assertEquals($f->find(), $current, '::find() returns the executable php');
|
||||
}
|
||||
|
||||
/**
|
||||
* tests find() with default executable
|
||||
*/
|
||||
public function testFindWithSuffix()
|
||||
{
|
||||
if (defined('PHP_BINARY')) {
|
||||
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
|
||||
}
|
||||
|
||||
putenv('PHP_PATH=');
|
||||
putenv('PHP_PEAR_PHP_BIN=');
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
$current = $f->find();
|
||||
|
||||
//TODO maybe php executable is custom or even windows
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertTrue(is_executable($current));
|
||||
$this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable php with suffixes');
|
||||
}
|
||||
}
|
||||
}
|
29
vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php
vendored
Normal file
29
vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\PhpProcess;
|
||||
|
||||
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNonBlockingWorks()
|
||||
{
|
||||
$expected = 'hello world!';
|
||||
$process = new PhpProcess(<<<PHP
|
||||
<?php echo '$expected';
|
||||
PHP
|
||||
);
|
||||
$process->start();
|
||||
$process->wait();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
}
|
200
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php
vendored
Normal file
200
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\ProcessBuilder;
|
||||
|
||||
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInheritEnvironmentVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = $expected = array('foo' => 'bar');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('foo')->inheritEnvironmentVariables();
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertNull($proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testProcessShouldInheritAndOverrideEnvironmentVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
|
||||
$expected = array('foo' => 'foo', 'bar' => 'baz');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('foo')->inheritEnvironmentVariables()
|
||||
->setEnv('foo', 'foo');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testProcessBuilderShouldNotPassEnvArrays()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('a' => array('b', 'c'), 'd' => 'e', 'f' => 'g');
|
||||
$expected = array('d' => 'e', 'f' => 'g');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('a')->inheritEnvironmentVariables()
|
||||
->setEnv('d', 'e');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() removes array values from $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testInheritEnvironmentVarsByDefault()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$proc = $pb->add('foo')->getProcess();
|
||||
|
||||
$this->assertNull($proc->getEnv());
|
||||
}
|
||||
|
||||
public function testNotReplaceExplicitlySetVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('foo' => 'bar');
|
||||
$expected = array('foo' => 'baz');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb
|
||||
->setEnv('foo', 'baz')
|
||||
->inheritEnvironmentVariables()
|
||||
->add('foo')
|
||||
;
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromSetter()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setTimeout(-1);
|
||||
}
|
||||
|
||||
public function testNullTimeout()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setTimeout(10);
|
||||
$pb->setTimeout(null);
|
||||
|
||||
$r = new \ReflectionObject($pb);
|
||||
$p = $r->getProperty('timeout');
|
||||
$p->setAccessible(true);
|
||||
|
||||
$this->assertNull($p->getValue($pb));
|
||||
}
|
||||
|
||||
public function testShouldSetArguments()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('initial'));
|
||||
$pb->setArguments(array('second'));
|
||||
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertContains("second", $proc->getCommandLine());
|
||||
}
|
||||
|
||||
public function testPrefixIsPrependedToAllGeneratedProcess()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setPrefix('/usr/bin/php');
|
||||
|
||||
$proc = $pb->setArguments(array('-v'))->getProcess();
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
|
||||
}
|
||||
|
||||
$proc = $pb->setArguments(array('-i'))->getProcess();
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArguments()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('%path%', 'foo " bar'));
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArgumentsAndPrefix()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('arg'));
|
||||
$pb->setPrefix('%prefix%');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testShouldThrowALogicExceptionIfNoPrefixAndNoArgument()
|
||||
{
|
||||
ProcessBuilder::create()->getProcess();
|
||||
}
|
||||
|
||||
public function testShouldNotThrowALogicExceptionIfNoArgument()
|
||||
{
|
||||
$process = ProcessBuilder::create()
|
||||
->setPrefix('/usr/bin/php')
|
||||
->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldNotThrowALogicExceptionIfNoPrefix()
|
||||
{
|
||||
$process = ProcessBuilder::create(array('/usr/bin/php'))
|
||||
->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
}
|
83
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
83
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
/**
|
||||
* @author Sebastian Marek <proofek@gmail.com>
|
||||
*/
|
||||
class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* tests ProcessFailedException throws exception if the process was successful
|
||||
*/
|
||||
public function testProcessFailedExceptionThrowsException()
|
||||
{
|
||||
$process = $this->getMock(
|
||||
'Symfony\Component\Process\Process',
|
||||
array('isSuccessful'),
|
||||
array('php')
|
||||
);
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->setExpectedException(
|
||||
'\InvalidArgumentException',
|
||||
'Expected a failed process, but the given process was successful.'
|
||||
);
|
||||
|
||||
new ProcessFailedException($process);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests ProcessFailedException uses information from process output
|
||||
* to generate exception message
|
||||
*/
|
||||
public function testProcessFailedExceptionPopulatesInformationFromProcessOutput()
|
||||
{
|
||||
$cmd = 'php';
|
||||
$exitCode = 1;
|
||||
$exitText = 'General error';
|
||||
$output = "Command output";
|
||||
$errorOutput = "FATAL: Unexpected error";
|
||||
|
||||
$process = $this->getMock(
|
||||
'Symfony\Component\Process\Process',
|
||||
array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText'),
|
||||
array($cmd)
|
||||
);
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->will($this->returnValue(false));
|
||||
$process->expects($this->once())
|
||||
->method('getOutput')
|
||||
->will($this->returnValue($output));
|
||||
$process->expects($this->once())
|
||||
->method('getErrorOutput')
|
||||
->will($this->returnValue($errorOutput));
|
||||
$process->expects($this->once())
|
||||
->method('getExitCode')
|
||||
->will($this->returnValue($exitCode));
|
||||
$process->expects($this->once())
|
||||
->method('getExitCodeText')
|
||||
->will($this->returnValue($exitText));
|
||||
|
||||
$exception = new ProcessFailedException($process);
|
||||
|
||||
$this->assertEquals(
|
||||
"The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}",
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
22
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessInSigchildEnvironment.php
vendored
Normal file
22
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessInSigchildEnvironment.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class ProcessInSigchildEnvironment extends Process
|
||||
{
|
||||
protected function isSigchildEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
63
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php
vendored
Normal file
63
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define('ERR_SELECT_FAILED', 1);
|
||||
define('ERR_TIMEOUT', 2);
|
||||
define('ERR_READ_FAILED', 3);
|
||||
define('ERR_WRITE_FAILED', 4);
|
||||
|
||||
$read = array(STDIN);
|
||||
$write = array(STDOUT, STDERR);
|
||||
|
||||
stream_set_blocking(STDIN, false);
|
||||
stream_set_blocking(STDOUT, false);
|
||||
stream_set_blocking(STDERR, false);
|
||||
|
||||
$out = $err = '';
|
||||
while ($read || $write) {
|
||||
$r = $read;
|
||||
$w = $write;
|
||||
$e = null;
|
||||
$n = stream_select($r, $w, $e, 5);
|
||||
|
||||
if (false === $n) {
|
||||
die(ERR_SELECT_FAILED);
|
||||
} elseif ($n < 1) {
|
||||
die(ERR_TIMEOUT);
|
||||
}
|
||||
|
||||
if (in_array(STDOUT, $w) && strlen($out) > 0) {
|
||||
$written = fwrite(STDOUT, (binary) $out, 1024);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$out = (binary) substr($out, $written);
|
||||
}
|
||||
if (null === $read && strlen($out) < 1) {
|
||||
$write = array_diff($write, array(STDOUT));
|
||||
}
|
||||
|
||||
if (in_array(STDERR, $w) && strlen($err) > 0) {
|
||||
$written = fwrite(STDERR, (binary) $err, 1024);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$err = (binary) substr($err, $written);
|
||||
}
|
||||
if (null === $read && strlen($err) < 1) {
|
||||
$write = array_diff($write, array(STDERR));
|
||||
}
|
||||
|
||||
if ($r) {
|
||||
$str = fread(STDIN, 1024);
|
||||
if (false !== $str) {
|
||||
$out .= $str;
|
||||
$err .= $str;
|
||||
}
|
||||
if (false === $str || feof(STDIN)) {
|
||||
$read = null;
|
||||
if (!feof(STDIN)) {
|
||||
die(ERR_READ_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php
vendored
Normal file
44
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\ProcessUtils;
|
||||
|
||||
class ProcessUtilsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider dataArguments
|
||||
*/
|
||||
public function testEscapeArgument($result, $argument)
|
||||
{
|
||||
$this->assertSame($result, ProcessUtils::escapeArgument($argument));
|
||||
}
|
||||
|
||||
public function dataArguments()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
return array(
|
||||
array('"foo bar"', 'foo bar'),
|
||||
array('^%"path"^%', '%path%'),
|
||||
array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'),
|
||||
array('""', ''),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
array("'foo bar'", 'foo bar'),
|
||||
array("'%path%'", '%path%'),
|
||||
array("'<|>\" \"'\\''f'", '<|>" "\'f'),
|
||||
array("''", ''),
|
||||
);
|
||||
}
|
||||
}
|
188
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php
vendored
Normal file
188
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildDisabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCode()
|
||||
{
|
||||
parent::testGetExitCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCodeIsNullOnStart()
|
||||
{
|
||||
parent::testGetExitCodeIsNullOnStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||
{
|
||||
parent::testGetExitCodeIsNullOnWhenStartingAgain();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
parent::testExitCodeCommandFailed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testCheckTimeoutOnStartedProcess()
|
||||
{
|
||||
parent::testCheckTimeoutOnStartedProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPid()
|
||||
{
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('qdfsmfkqsdfmqmsd');
|
||||
$process->run();
|
||||
|
||||
$process->getExitCodeText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
parent::testIsSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsSuccessfulOnlyAfterTerminated()
|
||||
{
|
||||
parent::testIsSuccessfulOnlyAfterTerminated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
parent::testProcessWithoutTermSignalIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
$this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->markTestSkipped('Signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(false);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
116
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php
vendored
Normal file
116
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildEnabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPid()
|
||||
{
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('qdfsmfkqsdfmqmsd');
|
||||
$process->run();
|
||||
|
||||
$this->assertInternalType('string', $process->getExitCodeText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
parent::testProcessWithoutTermSignalIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->markTestSkipped('Signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(true);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
16
vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php
vendored
Normal file
16
vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// required for signal handling
|
||||
declare(ticks = 1);
|
||||
|
||||
pcntl_signal(SIGUSR1, function(){echo "Caught SIGUSR1"; exit;});
|
||||
|
||||
$n=0;
|
||||
|
||||
// ticks require activity to work - sleep(4); does not work
|
||||
while ($n < 400) {
|
||||
usleep(10000);
|
||||
$n++;
|
||||
}
|
||||
|
||||
return;
|
147
vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php
vendored
Normal file
147
vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class SimpleProcessTest extends AbstractProcessTest
|
||||
{
|
||||
private $enabledSigchild = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL);
|
||||
|
||||
$this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
|
||||
}
|
||||
|
||||
public function testGetExitCode()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetExitCode();
|
||||
}
|
||||
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testExitCodeCommandFailed();
|
||||
}
|
||||
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testExitCodeText();
|
||||
}
|
||||
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testIsSuccessful();
|
||||
}
|
||||
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
public function testGetPid()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
public function testSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalProcessNotRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalWithWrongIntSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalWithWrongNonIntSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
}
|
||||
|
||||
private function skipIfPHPSigchild()
|
||||
{
|
||||
if ($this->enabledSigchild) {
|
||||
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user