Merge branch '2.8'

* 2.8:
  [Process] Fix PhpProcess with phpdbg runtime

Conflicts:
	src/Symfony/Bridge/ProxyManager/composer.json
This commit is contained in:
Nicolas Grekas 2015-11-18 17:57:58 +01:00
commit dba51b40fc
9 changed files with 30 additions and 26 deletions

View File

@ -80,7 +80,7 @@
"doctrine/orm": "~2.4,>=2.4.5", "doctrine/orm": "~2.4,>=2.4.5",
"doctrine/doctrine-bundle": "~1.4", "doctrine/doctrine-bundle": "~1.4",
"monolog/monolog": "~1.11", "monolog/monolog": "~1.11",
"zendframework/zend-stdlib": "~2.5", "zendframework/zend-stdlib": "~2.2",
"ocramius/proxy-manager": "~0.4|~1.0", "ocramius/proxy-manager": "~0.4|~1.0",
"egulias/email-validator": "~1.2", "egulias/email-validator": "~1.2",
"symfony/security-acl": "~2.8|~3.0", "symfony/security-acl": "~2.8|~3.0",

10
phpunit
View File

@ -11,7 +11,7 @@
*/ */
// Please update when phpunit needs to be reinstalled with fresh deps: // Please update when phpunit needs to be reinstalled with fresh deps:
// Cache-Id-Version: 2015-11-09 12:13 UTC // Cache-Id-Version: 2015-11-18 14:14 UTC
use Symfony\Component\Process\ProcessUtils; use Symfony\Component\Process\ProcessUtils;
@ -23,12 +23,15 @@ $PHPUNIT_VERSION = PHP_VERSION_ID >= 70000 ? '5.0' : '4.8';
$PHPUNIT_DIR = __DIR__.'/.phpunit'; $PHPUNIT_DIR = __DIR__.'/.phpunit';
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; $PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
$PHP = ProcessUtils::escapeArgument($PHP); $PHP = ProcessUtils::escapeArgument($PHP);
if ('phpdbg' === PHP_SAPI) {
$PHP .= ' -qrr';
}
$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `where.exe composer.phar` : `which composer.phar`)) $COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `where.exe composer.phar` : `which composer.phar`))
? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER) ? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER)
: 'composer'; : 'composer';
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.md5")) { if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) {
// Build a standalone phpunit without symfony/yaml // Build a standalone phpunit without symfony/yaml
$oldPwd = getcwd(); $oldPwd = getcwd();
@ -49,7 +52,6 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
$zip->close(); $zip->close();
chdir("phpunit-$PHPUNIT_VERSION"); chdir("phpunit-$PHPUNIT_VERSION");
passthru("$COMPOSER remove --no-update symfony/yaml"); passthru("$COMPOSER remove --no-update symfony/yaml");
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"<=3.0.0\"");
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\"");
passthru("$COMPOSER install --prefer-source --no-progress --ansi"); passthru("$COMPOSER install --prefer-source --no-progress --ansi");
file_put_contents('phpunit', <<<EOPHP file_put_contents('phpunit', <<<EOPHP
@ -66,7 +68,7 @@ EOPHP
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge"))); passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge")));
symlink(realpath('../src/Symfony/Bridge/PhpUnit'), "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge"); symlink(realpath('../src/Symfony/Bridge/PhpUnit'), "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge");
} }
file_put_contents('.md5', md5_file(__FILE__)); file_put_contents(".$PHPUNIT_VERSION.md5", md5_file(__FILE__));
chdir($oldPwd); chdir($oldPwd);
} }

View File

@ -18,7 +18,7 @@
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"symfony/dependency-injection": "~2.8|~3.0", "symfony/dependency-injection": "~2.8|~3.0",
"zendframework/zend-stdlib": "~2.5", "zendframework/zend-stdlib": "~2.2",
"ocramius/proxy-manager": "~0.4|~1.0" "ocramius/proxy-manager": "~0.4|~1.0"
}, },
"require-dev": { "require-dev": {

View File

@ -41,8 +41,8 @@ class PhpExecutableFinder
} }
// PHP_BINARY return the current sapi executable // PHP_BINARY return the current sapi executable
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) { if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
return PHP_BINARY; return PHP_BINARY.($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
} }
if ($php = getenv('PHP_PATH')) { if ($php = getenv('PHP_PATH')) {
@ -76,9 +76,10 @@ class PhpExecutableFinder
{ {
$arguments = array(); $arguments = array();
// HHVM support
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
$arguments[] = '--php'; $arguments[] = '--php';
} elseif ('phpdbg' === PHP_SAPI) {
$arguments[] = '-qrr';
} }
return $arguments; return $arguments;

View File

@ -39,6 +39,13 @@ class PhpProcess extends Process
if (false === $php = $executableFinder->find()) { if (false === $php = $executableFinder->find()) {
$php = null; $php = null;
} }
if ('phpdbg' === PHP_SAPI) {
$file = tempnam(sys_get_temp_dir(), 'dbg');
file_put_contents($file, $script);
register_shutdown_function('unlink', $file);
$php .= ' '.ProcessUtils::escapeArgument($file);
$script = null;
}
parent::__construct($php, $cwd, $env, $script, $timeout, $options); parent::__construct($php, $cwd, $env, $script, $timeout, $options);
} }

View File

@ -285,7 +285,7 @@ class Process
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
// Workaround for the bug, when PTS functionality is enabled. // Workaround for the bug, when PTS functionality is enabled.
// @see : https://bugs.php.net/69442 // @see : https://bugs.php.net/69442
$ptsWorkaround = fopen('php://fd/0', 'r'); $ptsWorkaround = fopen(__FILE__, 'r');
} }
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options); $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);

View File

@ -28,7 +28,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
$phpBin = new PhpExecutableFinder(); $phpBin = new PhpExecutableFinder();
self::$phpBin = $phpBin->find(); self::$phpBin = 'phpdbg' === PHP_SAPI ? 'php' : $phpBin->find();
} }
public function testThatProcessDoesNotThrowWarningDuringRun() public function testThatProcessDoesNotThrowWarningDuringRun()
@ -81,7 +81,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
// exec is mandatory here since we send a signal to the process // exec is mandatory here since we send a signal to the process
// see https://github.com/symfony/symfony/issues/5030 about prepending // see https://github.com/symfony/symfony/issues/5030 about prepending
// command with exec // command with exec
$p = $this->getProcess('exec php '.__DIR__.'/NonStopableProcess.php 3'); $p = $this->getProcess('exec '.self::$phpBin.' '.__DIR__.'/NonStopableProcess.php 3');
$p->start(); $p->start();
usleep(100000); usleep(100000);
$start = microtime(true); $start = microtime(true);
@ -452,7 +452,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Windows does have /dev/tty support'); $this->markTestSkipped('Windows does have /dev/tty support');
} }
$process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"'); $process = $this->getProcess('echo "foo" >> /dev/null && '.self::$phpBin.' -r "usleep(100000);"');
$process->setTty(true); $process->setTty(true);
$process->start(); $process->start();
$this->assertTrue($process->isRunning()); $this->assertTrue($process->isRunning());
@ -712,7 +712,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$termSignal = defined('SIGKILL') ? SIGKILL : 9; $termSignal = defined('SIGKILL') ? SIGKILL : 9;
$process = $this->getProcess('exec php -r "while (true) {}"'); $process = $this->getProcess('exec '.self::$phpBin.' -r "while (true) {}"');
$process->start(); $process->start();
posix_kill($process->getPid(), $termSignal); posix_kill($process->getPid(), $termSignal);
@ -738,18 +738,6 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertNotEquals($process1->getOutput(), $process2->getOutput()); $this->assertNotEquals($process1->getOutput(), $process2->getOutput());
} }
public function testPhpDeadlock()
{
$this->markTestSkipped('Can cause 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(self::$phpBin.' -r "while (true) {}"');
$process->start();
// PHP will deadlock when it tries to cleanup $process
}
public function testRunProcessWithTimeout() public function testRunProcessWithTimeout()
{ {
$timeout = 0.5; $timeout = 0.5;

View File

@ -44,6 +44,8 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
$this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments'); $this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments');
} elseif ('phpdbg' === PHP_SAPI) {
$this->assertEquals($f->findArguments(), array('-qrr'), '::findArguments() returns phpdbg arguments');
} else { } else {
$this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments'); $this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');
} }

View File

@ -30,6 +30,10 @@ PHP
public function testCommandLine() public function testCommandLine()
{ {
if ('phpdbg' === PHP_SAPI) {
$this->markTestSkipped('phpdbg SAPI is not supported by this test.');
}
$process = new PhpProcess(<<<PHP $process = new PhpProcess(<<<PHP
<?php echo 'foobar'; <?php echo 'foobar';
PHP PHP