com phpruntests: change to use a single configuration file for testing: build.xml phpdefinitions.txt tests/rtTestBootstrap.php
tests/testcase/rtCleanExecutionTest.php
| From: | David Soria Parra | Date: | Thu, 10 May 2012 15:17:46 +0000 |
| Subject: | com phpruntests: change to use a single configuration file for testing: build.xml phpdefinitions.txt tests/rtTestBootstrap.php tests/testcase/rtCleanExecutionTest.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66282@lists.php.net to get a copy of this message | ||
Commit: 571e6cb00c85a618df98b9ab1333a1ece0b39bd5
Author: Zoe Slattery <zoe@php.net> Thu, 10 May 2012 15:17:46 +0000
Parents: 6e7a69ab6338792fd5aa277eebf00a4c952d5027
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=571e6cb00c85a618df98b9ab1333a1ece0b39bd5
Log:
change to use a single configuration file for testing
Changed paths:
M build.xml
A phpdefinitions.txt
M tests/rtTestBootstrap.php
M tests/testcase/rtCleanExecutionTest.php
Diff:
diff --git a/build.xml b/build.xml
index c5dc5f9..6e73e9b 100755
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<project name="runtests" default="qa" basedir=".">
+<property file="phpdefinitions.txt" />
<target name="clean">
<delete dir="_compare" />
@@ -51,7 +52,8 @@
<target name="compare" description="Old/New comparison of phpt
results..">
<fail unless="php" message="Path to standard PHP executable not defined, use
-Dphp=/path/to/php" />
- <fail unless="php_to_test" message="Path to test PHP source dir not defined,
use -Dphp_to_test=/path/to/php_source_dir" />
+ <fail unless="php_to_test" message="Path to test PHP source dir not defined,
use -Dphp_to_test=/path/to/php/to/test" />
+ <fail unless="php_source" message="Path to test PHP source dir not defined,
use -Dphp_to_test=/path/to/php_source_dir" />
<delete dir="_compare" />
@@ -64,8 +66,8 @@
<exec command="tar xfz QATESTS.tgz" dir="/tmp/phpruntests" />
- <exec command="${php} -n ${php_to_test}/run-tests.php -n -p ${php_to_test}/sapi/cli/php
/tmp/phpruntests/Zend /tmp/phpruntests/ext /tmp/phpruntests/sapi /tmp/phpruntests/tests >
${project.basedir}/_compare/old.out" dir="/tmp/phpruntests" passthru="true"
checkReturn="true"/>
- <exec command="${php} -n ${project.basedir}/src/run-tests.php -n -p
${php_to_test}/sapi/cli/php -o csv -s ${project.basedir}/_compare/new.out /tmp/phpruntests"
dir="/tmp/phpruntests" passthru="true" checkReturn="true" />
+ <exec command="${php} -n ${php_source}/run-tests.php -n -p ${php_to_test}
/tmp/phpruntests/Zend /tmp/phpruntests/ext /tmp/phpruntests/sapi /tmp/phpruntests/tests >
${project.basedir}/_compare/old.out" dir="/tmp/phpruntests" passthru="true"
checkReturn="true"/>
+ <exec command="${php} -n ${project.basedir}/src/run-tests.php -n -p ${php_to_test} -o
csv -s ${project.basedir}/_compare/new.out /tmp/phpruntests" dir="/tmp/phpruntests"
passthru="true" checkReturn="true" />
<exec command="${php} -n QA/compareNewOld.php ${project.basedir}/_compare/new.out
${project.basedir}/_compare/old.out phpruntests >
${project.basedir}/_compare/compare_new_old.out" dir="${project.basedir}"
passthru="true" checkReturn="true"/>
diff --git a/phpdefinitions.txt b/phpdefinitions.txt
new file mode 100644
index 0000000..d1e7c52
--- /dev/null
+++ b/phpdefinitions.txt
@@ -0,0 +1,9 @@
+# This file is used as a phing property file and is also read by rtTestBoootstrap.php to determine
which
+# PHP exectables to use in running unit tests
+
+#These are example settings, you will need to unomment and change them to the right paths on your
system
+#
+#php=/usr/bin/php
+#php_to_test=/usr/local/php540/bin/php
+#php_cgi_to_test=/usr/local/php540/bin/php-cgi
+#php_source=/Users/zoe/Applications/PHP/php-5.4.0
diff --git a/tests/rtTestBootstrap.php b/tests/rtTestBootstrap.php
index e7e5bf9..bbfe412 100644
--- a/tests/rtTestBootstrap.php
+++ b/tests/rtTestBootstrap.php
@@ -3,14 +3,31 @@
require_once __DIR__ . '/../src/rtAutoload.php';
/**
- * Define the Path to the PHP executable
+ * Check to see if the PHP and CGI executables are in a config file
*/
+if(file_exists(__DIR__ . '/../phpdefinitions.txt')) {
+ $phpdefs=file(__DIR__ . '/../phpdefinitions.txt');
+ foreach($phpdefs as $line) {
+ if(preg_match('/^php_to_test=(.*)/', $line, $matches)) {
+ define('RT_PHP_PATH', trim($matches[1]));
+ }
+ if(preg_match('/^php_cgi_to_test=(.*)/', $line, $matches)) {
+ define('RT_PHP_CGI_PATH', trim($matches[1]));
+ }
+ }
+}
+
+
+/**
+ * Fall back definition of Path to the PHPexecutable
+ */
+
if (!defined('RT_PHP_PATH')) {
define('RT_PHP_PATH', trim(shell_exec("which php")));
}
/**
- * Define the Path to the PHP CGI executable
+ * 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/rtCleanExecutionTest.php b/tests/testcase/rtCleanExecutionTest.php
index b48ecc8..0a056eb 100644
--- a/tests/testcase/rtCleanExecutionTest.php
+++ b/tests/testcase/rtCleanExecutionTest.php
@@ -8,6 +8,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase
private $path_to_tests;
private $sample_test;
private $sample_fail;
+
public function setUp()
{
@@ -25,7 +26,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase
public function testFileRun()
{
- //Create a new test configuration
+ //Create a new test configuration
$config = rtRuntestsConfiguration::getInstance(array('run-tests.php',
'-p', RT_PHP_PATH, $this->sample_test));
$config->configure();