zoe Fri, 11 May 2012 08:04:49 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=325655
Log: fix to do a better guess at finding the CGI executable Changed paths: U php/phpruntests/trunk/src/configuration/settings/rtPhpCgiExecutableSetting.php U php/phpruntests/trunk/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php U php/phpruntests/trunk/tests/testcase/rtGetExecutionTest.php Modified: php/phpruntests/trunk/src/configuration/settings/rtPhpCgiExecutableSetting.php =================================================================== --- php/phpruntests/trunk/src/configuration/settings/rtPhpCgiExecutableSetting.php 2012-05-11 05:30:34 UTC (rev 325654) +++ php/phpruntests/trunk/src/configuration/settings/rtPhpCgiExecutableSetting.php 2012-05-11 08:04:49 UTC (rev 325655) @@ -43,17 +43,24 @@ } /** - * @todo spriebsch: does this method need to be public, is it only called from get()? - * @todo zoe:This method only works if we are running from a PHP source tree, do we need to - * cope with /usr/local/bin/php for example? + * If the path tp the php cli executable is either: + * something/cli/php + * or, failing that, + * something/php + * we can make a guess at the path to the cgi executable */ - public function guessFromPhpCli($phpCli) + private function guessFromPhpCli($phpCli) { - if(substr(dirname($phpCli),-3) == 'cli') { - $pathLength = strlen(dirname($phpCli)) - 3; - $sapiDir = substr(dirname($phpCli), 0, $pathLength); - $this->phpCgiExecutable = $sapiDir."cgi/php-cgi"; - } + + if(substr($phpCli, -7) === "cli/php") { + $cgiGuess = substr($phpCli, 0, -7) . "cgi/php-cgi"; + }elseif( substr($phpCli, -3) === "php") { + $cgiGuess = substr($phpCli, 0, -3) . "php-cgi"; + }else{ + $cgiGuess = null; + } + + return $cgiGuess; } /** @@ -68,9 +75,10 @@ // We ask rtPhpExecutableSetting for the path to the PHP executable. $rtPhpExecutableSetting = new rtPhpExecutableSetting($this->configuration); - $this->guessFromPhpCli($rtPhpExecutableSetting->get()); + $phpCli=$rtPhpExecutableSetting->get(); + $this->phpCgiExecutable = $this->guessFromPhpCli($phpCli); + } - return $this->phpCgiExecutable; } } Modified: php/phpruntests/trunk/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php =================================================================== --- php/phpruntests/trunk/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php 2012-05-11 05:30:34 UTC (rev 325654) +++ php/phpruntests/trunk/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php 2012-05-11 08:04:49 UTC (rev 325655) @@ -27,25 +27,32 @@ $setPhp = $configuration->getSetting('TEST_PHP_EXECUTABLE'); - if (preg_match("/sapi/", $setPhp)) { - // Make no assertion bacuse the CGI executable can be guesed + if (substr($setPhp, -3) === "php") { + // Make no assertion because the CGI executable can be guesed } else { $this->assertEquals(null, $setting->get()); } } public function testSetFromCliExecutableName() { - $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/a/sapi/cli/php', 'test.phpt')); + $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/some/thing/php', 'test.phpt')); $configuration->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', null); $setting = new rtPhpCgiExecutableSetting($configuration); - $this->assertEquals('/a/sapi/cgi/php-cgi', $setting->get()); + $this->assertEquals('/some/thing/php-cgi', $setting->get()); } public function testSetFromCli2() { - $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/a/sapi/cli/php', 'test.phpt')); + $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/some/thing/sapi/cli/php', 'test.phpt')); $setting = new rtPhpCgiExecutableSetting($configuration); - $this->assertEquals('/a/sapi/cgi/php-cgi', $setting->get()); + $this->assertEquals('/some/thing/sapi/cgi/php-cgi', $setting->get()); } + public function testSetFromCli3() { + $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/some/thing/sapi/cli/phpblah', 'test.phpt')); + $setting = new rtPhpCgiExecutableSetting($configuration); + + $this->assertEquals(null, $setting->get()); + } + } ?> Modified: php/phpruntests/trunk/tests/testcase/rtGetExecutionTest.php =================================================================== --- php/phpruntests/trunk/tests/testcase/rtGetExecutionTest.php 2012-05-11 05:30:34 UTC (rev 325654) +++ php/phpruntests/trunk/tests/testcase/rtGetExecutionTest.php 2012-05-11 08:04:49 UTC (rev 325655) @@ -83,7 +83,7 @@ $setPhp = $config->getSetting('PhpExecutable'); - if (preg_match("/sapi/", $setPhp)) { + if (substr($setPhp, -3) === "php") { // Make no assertion bacuse the CGI executable can be guesed } else { $this->assertEquals(0, strlen($output));
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php