com phpruntests: valgrind input classes: src/configuration/preconditions/rtIsValgrindAvailable.php src/configuration/rtPreConditionList.php
src/rtClassMap.php src/testcase/rtPhpRunner.php src/texts/valgrindNotAvailable.txt tests/configuration/preconditions/rtIsValgrindAvailableTest.php
| From: | David Soria Parra | Date: | Sun, 26 Jul 2009 14:49:23 +0000 |
| Subject: | com phpruntests: valgrind input classes: src/configuration/preconditions/rtIsValgrindAvailable.php src/configuration/rtPreConditionList.php src/rtClassMap.php src/testcase/rtPhpRunner.php src/texts/valgrindNotAvailable.txt tests/configuration/preconditions/rtIsValgrindAvailableTest.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66307@lists.php.net to get a copy of this message | ||
Commit: b6e7604a5d5eb4ef50355fb025a38cc846d858be
Author: Zoe Slattery <zoe@php.net> Sun, 26 Jul 2009 14:49:23 +0000
Parents: 63111169502750b1b812ef65eec1499895c54ec7
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=b6e7604a5d5eb4ef50355fb025a38cc846d858be
Log:
valgrind input classes
Changed paths:
A src/configuration/preconditions/rtIsValgrindAvailable.php
M src/configuration/rtPreConditionList.php
M src/rtClassMap.php
M src/testcase/rtPhpRunner.php
A src/texts/valgrindNotAvailable.txt
A tests/configuration/preconditions/rtIsValgrindAvailableTest.php
Diff:
diff --git a/src/configuration/preconditions/rtIsValgrindAvailable.php
b/src/configuration/preconditions/rtIsValgrindAvailable.php
new file mode 100644
index 0000000..bb93391
--- /dev/null
+++ b/src/configuration/preconditions/rtIsValgrindAvailable.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * rtIsValgrindAvailable
+ *
+ * Class for checking whether the PCNTL extension is loaded.
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <zoe@php.net>
+ * @author Stefan Priebsch <spriebsch@php.net>
+ * @copyright 2009 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
+ * @link http://qa.php.net/
+ *
+ */
+class rtIsValgrindAvailable extends rtPreCondition
+{
+ /**
+ * Return the message associated with missing Valgrind
+ *
+ * @return text
+ */
+ public function getMessage()
+ {
+ return rtText::get('valgrindNotAvailable');
+ }
+
+ /**
+ * Check that the right version of valgrind is available
+ *
+ * @param rtRuntestsConfiguration $config
+ * @return boolean
+ */
+ public function check(rtRuntestsConfiguration $config)
+ {
+ if ($config->hasCommandLineOption('m')) {
+ $valgrind_cmd = "valgrind --version";
+ $phpRunner = new rtPhpRunner($valgrind_cmd);
+ $valgrind_header = $phpRunner->runPHP();
+
+
+ if (!$valgrind_header) {
+ //valgrind not available
+ return false;
+ } else {
+ $replace_count = 0;
+ $valgrind_version =
preg_replace("/valgrind-([0-9])\.([0-9])\.([0-9]+)([.-]\w+)?(\s+)/", '$1$2$3',
$valgrind_header, 1, $replace_count);
+ if ($replace_count != 1 || !is_numeric($valgrind_version)) {
+ //Valgrind returned invalid version info
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
+?>
\ No newline at end of file
diff --git a/src/configuration/rtPreConditionList.php b/src/configuration/rtPreConditionList.php
index e156825..83220dc 100644
--- a/src/configuration/rtPreConditionList.php
+++ b/src/configuration/rtPreConditionList.php
@@ -23,6 +23,7 @@ abstract class rtPreConditionList
'rtIsSafeModeDisabled',
'rtIsTestFileSpecified',
'rtIsPhpVersionCorrect',
+ 'rtIsValgrindAvailable',
);
/**
diff --git a/src/rtClassMap.php b/src/rtClassMap.php
index 603685c..523c8f7 100644
--- a/src/rtClassMap.php
+++ b/src/rtClassMap.php
@@ -19,6 +19,7 @@ $rtClassMap = array(
'rtIsProcOpenAvailable' =>
'configuration/preconditions/rtIsProcOpenAvailable.php',
'rtIsSafeModeDisabled' =>
'configuration/preconditions/rtIsSafeModeDisabled.php',
'rtIsTestFileSpecified' =>
'configuration/preconditions/rtIsTestFileSpecified.php',
+ 'rtIsValgrindAvailable' =>
'configuration/preconditions/rtIsValgrindAvailable.php',
'rtAddToCommandLine' =>
'configuration/rtAddToCommandLine.php',
'rtCommandLineOptions' =>
'configuration/rtCommandLineOptions.php',
'rtEnvironmentVariables' =>
'configuration/rtEnvironmentVariables.php',
diff --git a/src/testcase/rtPhpRunner.php b/src/testcase/rtPhpRunner.php
index 31eea7f..8ddb058 100644
--- a/src/testcase/rtPhpRunner.php
+++ b/src/testcase/rtPhpRunner.php
@@ -21,7 +21,7 @@ class rtPhpRunner
private $stdin;
private $timeOut;
- public function __construct($phpCommand, $environmentVariables, $currentWorkingDirectory,
$stdin = null, $timeOut = 60)
+ public function __construct($phpCommand, $environmentVariables=null,
$currentWorkingDirectory=null, $stdin = null, $timeOut = 60)
{
$this->phpCommand = $phpCommand;
$this->environmentVariables = $environmentVariables;
diff --git a/src/texts/valgrindNotAvailable.txt b/src/texts/valgrindNotAvailable.txt
new file mode 100644
index 0000000..c5ce93c
--- /dev/null
+++ b/src/texts/valgrindNotAvailable.txt
@@ -0,0 +1 @@
+Valgrind is not available or is not the correct version.
\ No newline at end of file
diff --git a/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
b/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
new file mode 100644
index 0000000..bfd212e
--- /dev/null
+++ b/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * rtIsvalgrindAvailableTest
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <zoe@php.net>
+ * @author Stefan Priebsch <spriebsch@php.net>
+ * @copyright 2009 The PHP Group
+ * @license http://www.php.net/license/3_01.txt
PHP License 3.01
+ * @link http://qa.php.net/
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '../../../../src/rtAutoload.php';
+
+
+class rtIsValgrindAvailableTest extends PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ $this->preCondition = new rtIsValgrindAvailable();
+ }
+
+ protected function tearDown()
+ {
+ unset($this->preCondition);
+ }
+
+ public function testIsAvailable()
+ {
+ $runtestsConfiguration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-m'));
+
+ $this->assertTrue($this->preCondition->check($runtestsConfiguration));
+ }
+
+ public function testGetMessage()
+ {
+
$this->assertEquals($this->preCondition->getMessage('valgrindNotAvailable'),
rtText::get('valgrindNotAvailable'));
+ }
+}
+?>