Updated PEAR and PEAR packages.
[timetracker.git] / WEB-INF / lib / pear / PEAR / RunTest.php
index 5182490..59dedbf 100644 (file)
@@ -10,7 +10,6 @@
  * @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
  */
@@ -38,7 +37,7 @@ putenv("PHP_PEAR_RUNTESTS=1");
  * @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
  */
@@ -60,7 +59,6 @@ class PEAR_RunTest
     var $ini_overwrites = array(
         'output_handler=',
         'open_basedir=',
-        'safe_mode=0',
         'disable_functions=',
         'output_buffering=Off',
         'display_errors=1',
@@ -75,7 +73,6 @@ class PEAR_RunTest
         'error_append_string=',
         'auto_prepend_file=',
         'auto_append_file=',
-        'magic_quotes_runtime=0',
         'xdebug.default_enable=0',
         'allow_url_fopen=1',
     );
@@ -84,7 +81,7 @@ class PEAR_RunTest
      * 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);
@@ -115,19 +112,11 @@ class PEAR_RunTest
     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;
@@ -231,12 +220,7 @@ class PEAR_RunTest
     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;
     }
@@ -275,10 +259,8 @@ class PEAR_RunTest
      */
     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');
@@ -340,7 +322,7 @@ class PEAR_RunTest
                 }
                 return 'SKIPPED';
             }
-            $this->_savephp = $this->_php;
+            $this->_savePHPBinary();
             $this->_php = $this->_options['cgi'];
         }
 
@@ -494,8 +476,6 @@ class PEAR_RunTest
         }
         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);
 
@@ -516,6 +496,9 @@ class PEAR_RunTest
                 $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'])) {
@@ -639,6 +622,11 @@ class PEAR_RunTest
         $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;
         }
@@ -954,6 +942,8 @@ $text
     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");
@@ -965,4 +955,18 @@ $text
             }
         }
     }
+
+    function _savePHPBinary()
+    {
+        $this->_savephp = $this->_php;
+    }
+
+    function _restorePHPBinary()
+    {
+        if (isset($this->_savephp))
+        {
+            $this->_php = $this->_savephp;
+            unset($this->_savephp);
+        }
+    }
 }