* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: RunTest.php 313024 2011-07-06 19:51:24Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.3
*/
var $ini_overwrites = array(
'output_handler=',
'open_basedir=',
- 'safe_mode=0',
'disable_functions=',
'output_buffering=Off',
'display_errors=1',
'error_append_string=',
'auto_prepend_file=',
'auto_append_file=',
- 'magic_quotes_runtime=0',
'xdebug.default_enable=0',
'allow_url_fopen=1',
);
* An object that supports the PEAR_Common->log() signature, or null
* @param PEAR_Common|null
*/
- function PEAR_RunTest($logger = null, $options = array())
+ function __construct($logger = null, $options = array())
{
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 0);
function system_with_timeout($commandline, $env = null, $stdin = null)
{
$data = '';
- if (version_compare(phpversion(), '5.0.0', '<')) {
- $proc = proc_open($commandline, array(
- 0 => array('pipe', 'r'),
- 1 => array('pipe', 'w'),
- 2 => array('pipe', 'w')
- ), $pipes);
- } else {
- $proc = proc_open($commandline, array(
- 0 => array('pipe', 'r'),
- 1 => array('pipe', 'w'),
- 2 => array('pipe', 'w')
- ), $pipes, null, $env, array('suppress_errors' => true));
- }
+ $proc = proc_open($commandline, array(
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w'),
+ 2 => array('pipe', 'w')
+ ), $pipes, null, $env, array('suppress_errors' => true));
if (!$proc) {
return false;
function _preparePhpBin($php, $file, $ini_settings)
{
$file = escapeshellarg($file);
- // This was fixed in php 5.3 and is not needed after that
- if (OS_WINDOWS && version_compare(PHP_VERSION, '5.3', '<')) {
- $cmd = '"'.escapeshellarg($php).' '.$ini_settings.' -f ' . $file .'"';
- } else {
- $cmd = $php . $ini_settings . ' -f ' . $file;
- }
+ $cmd = $php . $ini_settings . ' -f ' . $file;
return $cmd;
}
*/
function run($file, $ini_settings = array(), $test_number = 1)
{
- if (isset($this->_savephp)) {
- $this->_php = $this->_savephp;
- unset($this->_savephp);
- }
+ $this->_restorePHPBinary();
+
if (empty($this->_options['cgi'])) {
// try to see if php-cgi is in the path
$res = $this->system_with_timeout('php-cgi -v');
}
return 'SKIPPED';
}
- $this->_savephp = $this->_php;
+ $this->_savePHPBinary();
$this->_php = $this->_options['cgi'];
}
}
chdir($cwd); // in case the test moves us around
- $this->_testCleanup($section_text, $temp_clean);
-
/* when using CGI, strip the headers from the output */
$output = $this->_stripHeadersCGI($output);
$output .= "\n====EXPECTHEADERS FAILURE====:\n$changed";
}
}
+
+ $this->_testCleanup($section_text, $temp_clean);
+
// Does the output match what is expected?
do {
if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
$expectf = isset($section_text['EXPECTF']) ? $wanted_re : null;
$data = $this->generate_diff($wanted, $output, $returns, $expectf);
$res = $this->_writeLog($diff_filename, $data);
+ if (isset($this->_options['showdiff'])) {
+ $this->_logger->log(0, "========DIFF========");
+ $this->_logger->log(0, $data);
+ $this->_logger->log(0, "========DONE========");
+ }
if (PEAR::isError($res)) {
return $res;
}
function _testCleanup($section_text, $temp_clean)
{
if ($section_text['CLEAN']) {
+ $this->_restorePHPBinary();
+
// perform test cleanup
$this->save_text($temp_clean, $section_text['CLEAN']);
$output = $this->system_with_timeout("$this->_php $temp_clean 2>&1");
}
}
}
+
+ function _savePHPBinary()
+ {
+ $this->_savephp = $this->_php;
+ }
+
+ function _restorePHPBinary()
+ {
+ if (isset($this->_savephp))
+ {
+ $this->_php = $this->_savephp;
+ unset($this->_savephp);
+ }
+ }
}