zoe Sun, 26 Jul 2009 14:49:23 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=286359
Log:
valgrind input classes
Changed paths:
A
php/phpruntests/trunk/src/configuration/preconditions/rtIsValgrindAvailable.php
U php/phpruntests/trunk/src/configuration/rtPreConditionList.php
U php/phpruntests/trunk/src/rtClassMap.php
U php/phpruntests/trunk/src/testcase/rtPhpRunner.php
A php/phpruntests/trunk/src/texts/valgrindNotAvailable.txt
A
php/phpruntests/trunk/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
Added:
php/phpruntests/trunk/src/configuration/preconditions/rtIsValgrindAvailable.php
===================================================================
---
php/phpruntests/trunk/src/configuration/preconditions/rtIsValgrindAvailable.php
(rev 0)
+++
php/phpruntests/trunk/src/configuration/preconditions/rtIsValgrindAvailable.php
2009-07-26 14:49:23 UTC (rev 286359)
@@ -0,0 +1,57 @@
+<?php
+/**
+ * rtIsValgrindAvailable
+ *
+ * Class for checking whether the PCNTL extension is loaded.
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <[email protected]>
+ * @author Stefan Priebsch <[email protected]>
+ * @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
Modified: php/phpruntests/trunk/src/configuration/rtPreConditionList.php
===================================================================
--- php/phpruntests/trunk/src/configuration/rtPreConditionList.php
2009-07-26 14:47:43 UTC (rev 286358)
+++ php/phpruntests/trunk/src/configuration/rtPreConditionList.php
2009-07-26 14:49:23 UTC (rev 286359)
@@ -23,6 +23,7 @@
'rtIsSafeModeDisabled',
'rtIsTestFileSpecified',
'rtIsPhpVersionCorrect',
+ 'rtIsValgrindAvailable',
);
/**
Modified: php/phpruntests/trunk/src/rtClassMap.php
===================================================================
--- php/phpruntests/trunk/src/rtClassMap.php 2009-07-26 14:47:43 UTC (rev
286358)
+++ php/phpruntests/trunk/src/rtClassMap.php 2009-07-26 14:49:23 UTC (rev
286359)
@@ -19,6 +19,7 @@
'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',
Modified: php/phpruntests/trunk/src/testcase/rtPhpRunner.php
===================================================================
--- php/phpruntests/trunk/src/testcase/rtPhpRunner.php 2009-07-26 14:47:43 UTC
(rev 286358)
+++ php/phpruntests/trunk/src/testcase/rtPhpRunner.php 2009-07-26 14:49:23 UTC
(rev 286359)
@@ -21,7 +21,7 @@
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;
Added: php/phpruntests/trunk/src/texts/valgrindNotAvailable.txt
===================================================================
--- php/phpruntests/trunk/src/texts/valgrindNotAvailable.txt
(rev 0)
+++ php/phpruntests/trunk/src/texts/valgrindNotAvailable.txt 2009-07-26
14:49:23 UTC (rev 286359)
@@ -0,0 +1 @@
+Valgrind is not available or is not the correct version.
\ No newline at end of file
Added:
php/phpruntests/trunk/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
===================================================================
---
php/phpruntests/trunk/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
(rev 0)
+++
php/phpruntests/trunk/tests/configuration/preconditions/rtIsValgrindAvailableTest.php
2009-07-26 14:49:23 UTC (rev 286359)
@@ -0,0 +1,42 @@
+<?php
+/**
+ * rtIsvalgrindAvailableTest
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <[email protected]>
+ * @author Stefan Priebsch <[email protected]>
+ * @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'));
+ }
+}
+?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php