From 8ccb00b2bca6a04af566e45f386bd46edaa35962 Mon Sep 17 00:00:00 2001 From: zoe slattery Date: Mon, 21 May 2012 20:56:03 +0100 Subject: [PATCH] Fixing unit tests and invalid argument problem --- build.xml | 2 -- phpdefinitions.txt_sample | 14 +++++++----- src/configuration/rtRuntestsConfiguration.php | 1 + src/testrun/rtPhpTestRun.php | 8 ++++--- tests/rtTestBootstrap.php | 22 +++++-------------- tests/testcase/rtCookieExecutionTest.php | 3 ++- tests/testcase/rtDeflatePostExecutionTest.php | 10 +++++++-- tests/testcase/rtGetExecutionTest.php | 3 ++- tests/testcase/rtGzipPostExecutionTest.php | 10 +++++++-- tests/testcase/rtPostExecutionTest.php | 3 ++- tests/testcase/rtPostRawExecutionTest.php | 3 ++- 11 files changed, 44 insertions(+), 35 deletions(-) diff --git a/build.xml b/build.xml index 4c7630b..c17a71d 100755 --- a/build.xml +++ b/build.xml @@ -82,9 +82,7 @@ - - diff --git a/phpdefinitions.txt_sample b/phpdefinitions.txt_sample index 098f066..3363812 100644 --- a/phpdefinitions.txt_sample +++ b/phpdefinitions.txt_sample @@ -4,17 +4,21 @@ #These are example settings, you will change them to the right paths on your system #then copy this to phpdefinitions.txt # -#Your system defualt PHP -php=/usr/bin/php +#The version of PHP that you are using to run unit tests +php=/usr/local/php540naked/bin/php # #The version of PHP that you intend to test -php_to_test=/usr/local/php540/bin/php +php_to_test=/usr/local/php5xx/bin/php # #The version of PHP CGI that you intend to test -php_cgi_to_test=/usr/local/php540/bin/php-cgi +php_cgi_to_test=/usr/local/php5xx/bin/php-cgi +# +#If the versions of PHP that you intent to test have NOT been +#built --with-zlib, put zlib=0 on the next line. +zlib=1 # #The location of a copy run-tests.php for running comparison results (qa target) -php_source=/Users/zoe/Applications/PHP/php-5.4.0 +php_source=/Users/zoe/Workspaces/php-src # #Temporary (writable) directory - also used buy qa target temp_directory=/tmp diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index 744e9da..7db80ad 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -168,5 +168,6 @@ public function getMemoryToolCommand() { return $this->memoryTool->getCommand(); } + } ?> diff --git a/src/testrun/rtPhpTestRun.php b/src/testrun/rtPhpTestRun.php index 4e24632..f780df5 100644 --- a/src/testrun/rtPhpTestRun.php +++ b/src/testrun/rtPhpTestRun.php @@ -103,9 +103,11 @@ public function run() $redirects = $scheduler->getRedirectedTestCases(); - for($i=0; $igetName(); + if($redirects != null) { + for($i=0; $igetName(); + } } } diff --git a/tests/rtTestBootstrap.php b/tests/rtTestBootstrap.php index bbfe412..2e2d90f 100644 --- a/tests/rtTestBootstrap.php +++ b/tests/rtTestBootstrap.php @@ -14,23 +14,11 @@ if(preg_match('/^php_cgi_to_test=(.*)/', $line, $matches)) { define('RT_PHP_CGI_PATH', trim($matches[1])); } + if(preg_match('/^zlib=(.*)/', $line, $matches)) { + define('ZLIB', trim($matches[1])); + } } +} else { + echo "You must provide PHP versions in phpdefinitions.txt\n"; } - - -/** - * Fall back definition of Path to the PHPexecutable - */ - -if (!defined('RT_PHP_PATH')) { - define('RT_PHP_PATH', trim(shell_exec("which php"))); -} - -/** - * Fall back definition of Path to the PHP CGI executable - */ -if (!defined('RT_PHP_CGI_PATH')) { - define('RT_PHP_CGI_PATH', trim(shell_exec("which php-cgi"))); -} - ?> diff --git a/tests/testcase/rtCookieExecutionTest.php b/tests/testcase/rtCookieExecutionTest.php index 67591ac..e759fd2 100644 --- a/tests/testcase/rtCookieExecutionTest.php +++ b/tests/testcase/rtCookieExecutionTest.php @@ -24,7 +24,8 @@ public function testFileRun() { //Create a new test configuration $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, $this->sample_test)); - $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE',RT_PHP_CGI_PATH); + //Need to get rid of xdebug in these tests, reformats the output so they fail. + $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE',RT_PHP_CGI_PATH." -n xdebug.default_enable=0"); $config->configure(); //Retrieve the array of test file names diff --git a/tests/testcase/rtDeflatePostExecutionTest.php b/tests/testcase/rtDeflatePostExecutionTest.php index 6ede533..33e9b7c 100644 --- a/tests/testcase/rtDeflatePostExecutionTest.php +++ b/tests/testcase/rtDeflatePostExecutionTest.php @@ -9,8 +9,14 @@ class rtDeflatePostExecutionTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests . '/sample_deflatepost.phpt'; + if(ZLIB == 0) { + $this->markTestSkipped( + 'The zlib extension is not available.' + ); + } else { + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_deflatepost.phpt'; + } } public function tearDown() diff --git a/tests/testcase/rtGetExecutionTest.php b/tests/testcase/rtGetExecutionTest.php index 0b24ed7..a666c65 100644 --- a/tests/testcase/rtGetExecutionTest.php +++ b/tests/testcase/rtGetExecutionTest.php @@ -25,7 +25,8 @@ public function testFileRun() { //Create a new test configuration $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, $this->sample_test)); - $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH); + //Need to get rid of xdebug in these tests, reformats the output so they fail. + $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH." -d xdebug.default_enable=0"); $config->configure(); //Retrieve the array of test file names diff --git a/tests/testcase/rtGzipPostExecutionTest.php b/tests/testcase/rtGzipPostExecutionTest.php index f1abc2c..5aa4c53 100644 --- a/tests/testcase/rtGzipPostExecutionTest.php +++ b/tests/testcase/rtGzipPostExecutionTest.php @@ -9,8 +9,14 @@ class rtGzipPostExecutionTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); - $this->sample_test = $this->path_to_tests . '/sample_gzippost.phpt'; + if(ZLIB == 0) { + $this->markTestSkipped( + 'The zlib extension is not available.' + ); + } else { + $this->path_to_tests = realpath(dirname(__FILE__) . '/../../phpt-tests'); + $this->sample_test = $this->path_to_tests . '/sample_gzippost.phpt'; + } } public function tearDown() diff --git a/tests/testcase/rtPostExecutionTest.php b/tests/testcase/rtPostExecutionTest.php index e77b18a..23f537f 100644 --- a/tests/testcase/rtPostExecutionTest.php +++ b/tests/testcase/rtPostExecutionTest.php @@ -23,7 +23,8 @@ public function testFileRun() { //Create a new test configuration $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, $this->sample_test)); - $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH); + //Need to get rid of xdebug in these tests, reformats the output so they fail. + $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH." -d xdebug.default_enable=0"); $config->configure(); //Retrieve the array of test file names diff --git a/tests/testcase/rtPostRawExecutionTest.php b/tests/testcase/rtPostRawExecutionTest.php index 0cebd90..8aad725 100644 --- a/tests/testcase/rtPostRawExecutionTest.php +++ b/tests/testcase/rtPostRawExecutionTest.php @@ -23,7 +23,8 @@ public function testFileRun() { //Create a new test configuration $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, $this->sample_test)); - $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH); + //Need to get rid of xdebug in these tests, reformats the output so they fail. + $config->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', RT_PHP_CGI_PATH." -d xdebug.default_enable=0"); $config->configure(); //Retrieve the array of test file names