com phpruntests: phpruntests: added php-version-check to run-tests.php: src/configuration/preconditions/rtIsPhpVersionCorrect.php src/run-tests.php
| From: | David Soria Parra | Date: | Thu, 07 May 2009 20:58:45 +0000 |
| Subject: | com phpruntests: phpruntests: added php-version-check to run-tests.php: src/configuration/preconditions/rtIsPhpVersionCorrect.php src/run-tests.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66493@lists.php.net to get a copy of this message | ||
Commit: 2efda10635fa9db3891c2a413b9af4aa7f87ab7b
Author: Georg Gradwohl <g2@php.net> Thu, 7 May 2009 20:58:45 +0000
Parents: db086690e2a776fd9c15803eb9cda1fb2bd12b45
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=2efda10635fa9db3891c2a413b9af4aa7f87ab7b
Log:
phpruntests: added php-version-check to run-tests.php
Changed paths:
M src/configuration/preconditions/rtIsPhpVersionCorrect.php
M src/run-tests.php
Diff:
diff --git a/src/configuration/preconditions/rtIsPhpVersionCorrect.php
b/src/configuration/preconditions/rtIsPhpVersionCorrect.php
index 2fae325..cd3e8d4 100644
--- a/src/configuration/preconditions/rtIsPhpVersionCorrect.php
+++ b/src/configuration/preconditions/rtIsPhpVersionCorrect.php
@@ -51,19 +51,6 @@ class rtIsPhpVersionCorrect extends rtPreCondition
*/
public function check(rtRuntestsConfiguration $config)
{
- return ($this->checkRunVersion() && $this->checkExecVersion($config));
- }
-
- /**
- * check that executing php-version matches the precondition
- *
- * @param rtRuntestsConfiguration $config
- *
- * @return boolean
- * @access private
- */
- private function checkExecVersion(rtRuntestsConfiguration $config)
- {
$exec = escapeshellcmd($config->getSetting('PhpExecutable').' -v');
$pipe = popen($exec, "r");
@@ -74,17 +61,6 @@ class rtIsPhpVersionCorrect extends rtPreCondition
}
/**
- * check that running php-version matches the precondition
- *
- * @return boolean
- * @access private
- */
- private function checkRunVersion()
- {
- return $this->parseVersionString('PHP '.phpversion());
- }
-
- /**
* parses the version-string and checks the required minimun-version
*
* @param string $versionStr output of "php -v"
@@ -94,8 +70,8 @@ class rtIsPhpVersionCorrect extends rtPreCondition
*/
public function parseVersionString($versionStr)
{
- $major = substr($versionStr, 4,1);
- $minor = substr($versionStr, 6,1);
+ $major = substr($versionStr, 4, 1);
+ $minor = substr($versionStr, 6, 1);
if ($major > $this->requiredMajorVersion) {
return true;
diff --git a/src/run-tests.php b/src/run-tests.php
index b5ec154..5d8889d 100644
--- a/src/run-tests.php
+++ b/src/run-tests.php
@@ -2,12 +2,40 @@
/*
* Main php file for run-tests.php
*/
-require_once dirname(__FILE__) . '/rtAutoload.php';
+/*
+ * check the version of the running php-executable and
+ * ensure that is 5.3 or higher
+ */
+$v = phpversion();
+
+$major = substr($v, 0, 1);
+$minor = substr($v, 2, 1);
+
+$isVersionOk = false;
+
+if ($major > 5) {
+ $isVersionOk = true;
+
+} elseif ($major == 5) {
+
+ if ($minor >= 3) {
+ $isVersionOk = true;
+ }
+}
+
+
+if ($isVersionOk) {
+
+ require_once dirname(__FILE__) . '/rtAutoload.php';
-$phpTestRun = new rtPhpTestRun($argv);
-$phpTestRun->run();
+ $phpTestRun = new rtPhpTestRun($argv);
+ $phpTestRun->run();
+} else {
+
+ die("This version of run-tests requires PHP 5.3 or higher.\nYou can check your current
version by executing 'php -v' from the command line.\n");
+}
?>