jani            Mon Jul 21 10:48:31 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src    run-tests.php 
  Log:
  MFH: Stupid WS fixes..Thanks Steph!
  
http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.226.2.37.2.35.2.32&r2=1.226.2.37.2.35.2.33&diff_format=u
Index: php-src/run-tests.php
diff -u php-src/run-tests.php:1.226.2.37.2.35.2.32 
php-src/run-tests.php:1.226.2.37.2.35.2.33
--- php-src/run-tests.php:1.226.2.37.2.35.2.32  Mon Jul 21 09:59:37 2008
+++ php-src/run-tests.php       Mon Jul 21 10:48:31 2008
@@ -24,7 +24,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: run-tests.php,v 1.226.2.37.2.35.2.32 2008/07/21 09:59:37 bjori Exp $ */
+/* $Id: run-tests.php,v 1.226.2.37.2.35.2.33 2008/07/21 10:48:31 jani Exp $ */
 
 /* Sanity check to ensure that pcre extension needed by this script is 
available.
  * In the event it is not, print a nice error message indicating that this 
script will
@@ -109,20 +109,23 @@
 // Require the explicit specification.
 // Otherwise we could end up testing the wrong file!
 
-$php = NULL;
-$php_cgi = NULL;
+$php = null;
+$php_cgi = null;
 
 if (getenv('TEST_PHP_EXECUTABLE')) {
        $php = getenv('TEST_PHP_EXECUTABLE');
+
        if ($php=='auto') {
                $php = $cwd.'/sapi/cli/php';
                putenv("TEST_PHP_EXECUTABLE=$php");
+
                if (!getenv('TEST_PHP_CGI_EXECUTABLE')) {
                        $php_cgi = $cwd.'/sapi/cgi/php-cgi';
+
                        if (file_exists($php_cgi)) {
                                putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi");
                        } else {
-                               $php_cgi = NULL;
+                               $php_cgi = null;
                        }
                }
        }
@@ -131,10 +134,12 @@
 
 if (getenv('TEST_PHP_CGI_EXECUTABLE')) {
        $php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE');
+
        if ($php_cgi=='auto') {
                $php_cgi = $cwd.'/sapi/cgi/php-cgi';
                putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi");
        }
+
        $environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi;
 }
 
@@ -145,6 +150,7 @@
        if (empty($php) || !file_exists($php)) {
                error("environment variable TEST_PHP_EXECUTABLE must be set to 
specify PHP executable!");
        }
+
        if (function_exists('is_executable') && [EMAIL PROTECTED]($php)) {
                error("invalid PHP executable specified by TEST_PHP_EXECUTABLE  
= " . $php);
        }
@@ -165,7 +171,7 @@
 
 // Check whether user test dirs are requested.
 if (getenv('TEST_PHP_USER')) {
-       $user_tests = explode (',', getenv('TEST_PHP_USER'));
+       $user_tests = explode (', ', getenv('TEST_PHP_USER'));
 } else {
        $user_tests = array();
 }
@@ -211,10 +217,11 @@
 More .INIs  : " . (function_exists(\'php_ini_scanned_files\') ? 
str_replace("\n","", php_ini_scanned_files()) : "** not determined **"); ?>';
        save_text($info_file, $php_info);
        $info_params = array();
-       settings2array($ini_overwrites,$info_params);
+       settings2array($ini_overwrites, $info_params);
        settings2params($info_params);
        $php_info = `$php $pass_options $info_params "$info_file"`;
        define('TESTED_PHP_VERSION', `$php -r "echo PHP_VERSION;"`);
+
        if ($php_cgi && $php != $php_cgi) {
                $php_info_cgi = `$php_cgi $pass_options $info_params -q 
"$info_file"`;
                $php_info_sep = 
"\n---------------------------------------------------------------------";
@@ -235,11 +242,13 @@
                'xdebug' => array('xdebug.default_enable=0'),
                'mbstring' => array('mbstring.func_overload=0'),
        );
+
        foreach($info_params_ex as $ext => $ini_overwrites_ex) {
                if (in_array($ext, $exts_to_test)) {
                        $ini_overwrites = array_merge($ini_overwrites, 
$ini_overwrites_ex);
                }
        }
+
        @unlink($info_file);
 
        // Write test context information.
@@ -271,9 +280,11 @@
 
 $compression = 0;
 $output_file = $CUR_DIR . '/php_test_results_' . @date('Ymd_Hi') . '.txt';
+
 if ($compression) {
        $output_file = 'compress.zlib://' . $output_file . '.gz';
 }
+
 $just_save_results = false;
 $leak_check = false;
 $html_output = false;
@@ -287,38 +298,45 @@
 $cfgtypes = array('show', 'keep');
 $cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp');
 $cfg = array();
+
 foreach($cfgtypes as $type) {
        $cfg[$type] = array();
+
        foreach($cfgfiles as $file) {
                $cfg[$type][$file] = false;
        }
 }
 
-if (getenv('TEST_PHP_ARGS'))
-{
-       if (!isset($argc) || !$argc || !isset($argv))
-       {
+if (getenv('TEST_PHP_ARGS')) {
+
+       if (!isset($argc) || !$argc || !isset($argv)) {
                $argv = array(__FILE__);
        }
+
        $argv = array_merge($argv, split(' ', getenv('TEST_PHP_ARGS')));
        $argc = count($argv);
 }
 
 if (isset($argc) && $argc > 1) {
+
        for ($i=1; $i<$argc; $i++) {
                $is_switch = false;
                $switch = substr($argv[$i],1,1);
                $repeat = substr($argv[$i],0,1) == '-';
+
                while ($repeat) {
+
                        if (!$is_switch) {
                                $switch = substr($argv[$i],1,1);
                        }
+
                        $is_switch = true;
+
                        if ($repeat) {
                                foreach($cfgtypes as $type) {
-                                       if (strpos($switch, '--'.$type) === 0) {
+                                       if (strpos($switch, '--' . $type) === 
0) {
                                                foreach($cfgfiles as $file) {
-                                                       if ($switch == 
'--'.$type.'-'.$file) {
+                                                       if ($switch == '--' . 
$type.'-' . $file) {
                                                                
$cfg[$type][$file] = true;
                                                                $is_switch = 
false;
                                                                break;
@@ -327,11 +345,14 @@
                                        }
                                }
                        }
+
                        if (!$is_switch) {
                                $is_switch = true;
                                break;
                        }
+
                        $repeat = false;
+
                        switch($switch) {
                                case 'r':
                                case 'l':
@@ -449,7 +470,7 @@
                                        $html_output = is_resource($html_file);
                                        break;
                                case '--version':
-                                       echo '$Revision: 1.226.2.37.2.35.2.32 
$'."\n";
+                                       echo '$Revision: 1.226.2.37.2.35.2.33 
$'."\n";
                                        exit(1);
 
                                case 'u':
@@ -518,7 +539,7 @@
     --show-[all|php|skip|clean|exp|diff|out]
                 Show 'all' files, 'php' test file, 'skip' or 'clean' file. You
                 can also use this to show the output 'out', the expected result
-                'exp' or the difference between them 'exp'. The result types
+                'exp' or the difference between them 'diff'. The result types
                 get written independent of the log format, however 'diff' only
                 exists when a test fails.
 
@@ -528,9 +549,12 @@
                                        exit(1);
                        }
                }
+
                if (!$is_switch) {
                        $testfile = realpath($argv[$i]);
+
                        if (!$testfile && strpos($argv[$i], '*') !== false && 
function_exists('glob')) {
+
                                if (preg_match("/\.phpt$/", $argv[$i])) {
                                        $pattern_match = glob($argv[$i]);
                                } else if (preg_match("/\*$/", $argv[$i])) {
@@ -538,9 +562,11 @@
                                } else {
                                        die("bogus test name " . $argv[$i] . 
"\n");
                                }
+
                                if (is_array($pattern_match)) {
                                        $test_files = array_merge($test_files, 
$pattern_match);
                                }
+
                        } else if (is_dir($testfile)) {
                                find_files($testfile);
                        } else if (preg_match("/\.phpt$/", $testfile)) {
@@ -590,12 +616,15 @@
                        echo 
"=====================================================================";
                        echo get_summary(false, false);
                }
+
                if ($html_output) {
                        fclose($html_file);
                }
+
                if (getenv('REPORT_EXIT_STATUS') == 1 and 
preg_match('/FAILED(?: |$)/', implode(' ', $test_results))) {
                        exit(1);
                }
+
                exit(0);
        }
 }
@@ -611,6 +640,7 @@
 sort($exts_to_test);
 $test_dirs = array();
 $optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 
'sapi/cgi');
+
 foreach($optionals as $dir) {
        if (@filetype($dir) == 'dir') {
                $test_dirs[] = $dir;
@@ -630,18 +660,20 @@
        find_files($dir, ($dir == 'ext'));
 }
 
-function find_files($dir,$is_ext_dir=FALSE,$ignore=FALSE)
+function find_files($dir, $is_ext_dir = false, $ignore = false)
 {
        global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, 
$exts_tested;
 
        $o = opendir($dir) or error("cannot open directory: $dir");
-       while (($name = readdir($o)) !== FALSE) {
+
+       while (($name = readdir($o)) !== false) {
+
                if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', 
'..', 'CVS'))) {
                        $skip_ext = ($is_ext_dir && 
!in_array(strtolower($name), $exts_to_test));
                        if ($skip_ext) {
                                $exts_skipped++;
                        }
-                       find_files("{$dir}/{$name}", FALSE, $ignore || 
$skip_ext);
+                       find_files("{$dir}/{$name}", false, $ignore || 
$skip_ext);
                }
 
                // Cleanup any left-over tmp files from last run.
@@ -660,6 +692,7 @@
                        }
                }
        }
+
        closedir($o);
 }
 
@@ -679,8 +712,9 @@
        $a = test_name($a);
        $b = test_name($b);
 
-       $ta = strpos($a, "{$cwd}/tests")===0 ? 1 + (strpos($a, 
"{$cwd}/tests/run-test")===0 ? 1 : 0) : 0;
-       $tb = strpos($b, "{$cwd}/tests")===0 ? 1 + (strpos($b, 
"{$cwd}/tests/run-test")===0 ? 1 : 0) : 0;
+       $ta = strpos($a, "{$cwd}/tests") === 0 ? 1 + (strpos($a, 
"{$cwd}/tests/run-test") === 0 ? 1 : 0) : 0;
+       $tb = strpos($b, "{$cwd}/tests") === 0 ? 1 + (strpos($b, 
"{$cwd}/tests/run-test") === 0 ? 1 : 0) : 0;
+
        if ($ta == $tb) {
                return strcmp($a, $b);
        } else {
@@ -698,6 +732,7 @@
 $test_idx = 0;
 run_all_tests($test_files, $environment);
 $end_time = time();
+
 if ($failed_tests_file) {
        fclose($failed_tests_file);
 }
@@ -732,21 +767,23 @@
        echo "immediately, you can choose \"s\" to save the report to\na file 
that you can send us later.\n";
        echo "Do you want to send this report now? [Yns]: ";
        flush();
+
        $user_input = fgets($fp, 10);
        $just_save_results = (strtolower($user_input[0]) == 's');
 }
-if ($just_save_results || !getenv('NO_INTERACTION')) { 
+
+if ($just_save_results || !getenv('NO_INTERACTION')) {
        if ($just_save_results || strlen(trim($user_input)) == 0 || 
strtolower($user_input[0]) == 'y') {
-               /*  
+               /*
                 * Collect information about the host system for our report
                 * Fetch phpinfo() output so that we can see the PHP enviroment
                 * Make an archive of all the failed tests
                 * Send an email
                 */
-               if ($just_save_results)
-               {
+               if ($just_save_results) {
                        $user_input = 's';
                }
+
                /* Ask the user to provide an email address, so that QA team 
can contact the user */
                if (!strncasecmp($user_input, 'y', 1) || 
strlen(trim($user_input)) == 0) {
                        echo "\nPlease enter your email address.\n(Your address 
will be mangled so that it will not go out on any\nmailinglist in plain text): 
";
@@ -790,6 +827,7 @@
 
                        /* Use shtool to find out if there is glibtool present 
(MacOSX) */
                        $sys_libtool_path = shell_exec(__DIR__ . '/build/shtool 
path glibtool libtool');
+
                        if ($sys_libtool_path) {
                                $sys_libtool = shell_exec(str_replace("\n", "", 
$sys_libtool_path) . ' --version');
                        }
@@ -797,6 +835,7 @@
                        /* Try the most common flags for 'version' */
                        $flags = array('-v', '-V', '--version');
                        $cc_status=0;
+
                        foreach($flags AS $flag) {
                                system(getenv('CC')." $flag >/dev/null 2>&1", 
$cc_status);
                                if ($cc_status == 0) {
@@ -804,8 +843,10 @@
                                        break;
                                }
                        }
+
                        $ldd = shell_exec("ldd $php 2>/dev/null");
                }
+
                $failed_tests_data .= "Autoconf:\n$autoconf\n";
                $failed_tests_data .= "Bundled Libtool:\n$libtool\n";
                $failed_tests_data .= "System Libtool:\n$sys_libtool\n";
@@ -813,14 +854,14 @@
                $failed_tests_data .= "Bison:\n". @shell_exec('bison --version 
2>/dev/null'). "\n";
                $failed_tests_data .= "Libraries:\n$ldd\n";
                $failed_tests_data .= "\n";
-               
+
                if (isset($user_email)) {
-                       $failed_tests_data .= "User's E-mail: 
".$user_email."\n\n";
-               }       
-               
+                       $failed_tests_data .= "User's E-mail: " . 
$user_email."\n\n";
+               }
+
                $failed_tests_data .= $sep . "PHPINFO" . $sep;
                $failed_tests_data .= shell_exec($php.' -dhtml_errors=0 -i');
-               
+
                if ($just_save_results || !mail_qa_team($failed_tests_data, 
$compression, $status)) {
                        file_put_contents($output_file, $failed_tests_data);
 
@@ -828,11 +869,11 @@
                                echo "\nThe test script was unable to 
automatically send the report to PHP's QA Team\n";
                        }
 
-                       echo "Please send ".$output_file." to ".PHP_QA_EMAIL." 
manually, thank you.\n";
+                       echo "Please send " . $output_file . " to " . 
PHP_QA_EMAIL . " manually, thank you.\n";
                } else {
                        fwrite($fp, "\nThank you for helping to make PHP 
better.\n");
                        fclose($fp);
-               }       
+               }
        }
 }
  
@@ -845,35 +886,39 @@
 // Send Email to QA Team
 //
 
-function mail_qa_team($data, $compression, $status = FALSE)
+function mail_qa_team($data, $compression, $status = false)
 {
        $url_bits = parse_url(QA_SUBMISSION_PAGE);
-       if (empty($url_bits['port'])) $url_bits['port'] = 80;
-       
+
+       if (empty($url_bits['port'])) {
+               $url_bits['port'] = 80;
+       }
+
        $data = "php_test_data=" . urlencode(base64_encode(str_replace("\00", 
'[0x0]', $data)));
        $data_length = strlen($data);
        
        $fs = fsockopen($url_bits['host'], $url_bits['port'], $errno, $errstr, 
10);
+
        if (!$fs) {
-               return FALSE;
+               return false;
        }
 
        $php_version = urlencode(TESTED_PHP_VERSION);
 
        echo "\nPosting to {$url_bits['host']} {$url_bits['path']}\n";
-       fwrite($fs, "POST 
".$url_bits['path']."?status=$status&version=$php_version HTTP/1.1\r\n");
-       fwrite($fs, "Host: ".$url_bits['host']."\r\n");
+       fwrite($fs, "POST " . $url_bits['path'] . 
"?status=$status&version=$php_version HTTP/1.1\r\n");
+       fwrite($fs, "Host: " . $url_bits['host'] . "\r\n");
        fwrite($fs, "User-Agent: QA Browser 0.1\r\n");
        fwrite($fs, "Content-Type: application/x-www-form-urlencoded\r\n");
-       fwrite($fs, "Content-Length: ".$data_length."\r\n\r\n");
+       fwrite($fs, "Content-Length: " . $data_length . "\r\n\r\n");
        fwrite($fs, $data);
        fwrite($fs, "\r\n\r\n");
        fclose($fs);
 
        return 1;
 } 
- 
- 
+
+
 //
 //  Write the given text to a temporary file, and return the filename.
 //
@@ -887,9 +932,11 @@
                        error("Cannot open file '" . $filename_copy . "' 
(save_text)");
                }
        }
+
        if (@file_put_contents($filename, $text) === false) {
                error("Cannot open file '" . $filename . "' (save_text)");
        }
+
        if (1 < $DETAILED) echo "
 FILE $filename {{{
 $text
@@ -905,15 +952,16 @@
 {
        $testname = realpath($testname);
        $logname  = realpath($logname);
+
        switch (strtoupper(getenv('TEST_PHP_ERROR_STYLE'))) {
-       case 'MSVC':
-               echo $testname . "(1) : $tested\n";
-               echo $logname . "(1) :  $tested\n";
-               break;
-       case 'EMACS':
-               echo $testname . ":1: $tested\n";
-               echo $logname . ":1:  $tested\n";
-               break;
+               case 'MSVC':
+                       echo $testname . "(1) : $tested\n";
+                       echo $logname . "(1) :  $tested\n";
+                       break;
+               case 'EMACS':
+                       echo $testname . ":1: $tested\n";
+                       echo $logname . ":1:  $tested\n";
+                       break;
        }
 }
 
@@ -1006,15 +1054,17 @@
 //
 //  Show file or result block
 //
-function show_file_block($file, $block, $section=NULL)
+function show_file_block($file, $block, $section = null)
 {
        global $cfg;
 
        if ($cfg['show'][$file]) {
+
                if (is_null($section)) {
                        $section = strtoupper($file);
                }
-               echo "\n========".$section."========\n";
+
+               echo "\n========" . $section . "========\n";
                echo rtrim($block);
                echo "\n========DONE========\n";
        }
@@ -1038,7 +1088,9 @@
                $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE'];
        }
 
-       if (is_array($file)) $file = $file[0];
+       if (is_array($file)) {
+               $file = $file[0];
+       }
 
        if ($DETAILED) echo "
 =================
@@ -1082,7 +1134,7 @@
                        $secdone = false;
                        continue;
                }
-               
+
                // Add to the section text.
                if (!$secdone) {
                        $section_text[$section] .= $line;
@@ -1176,6 +1228,7 @@
        } else {
                $temp_dir = $test_dir = realpath(dirname($file));
        }
+
        if ($temp_source && $temp_target) {
                $temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
        }
@@ -1200,13 +1253,16 @@
                $temp_skipif  .= 's';
                $temp_file    .= 's';
                $temp_clean   .= 's';
-               $copy_file     = $temp_dir . DIRECTORY_SEPARATOR . 
basename(is_array($file) ? $file[1] : $file).'.phps';
+               $copy_file     = $temp_dir . DIRECTORY_SEPARATOR . 
basename(is_array($file) ? $file[1] : $file) . '.phps';
+
                if (!is_dir(dirname($copy_file))) {
                        @mkdir(dirname($copy_file), 0777, true) or 
error("Cannot create output directory - " . dirname($copy_file));
                }
+
                if (isset($section_text['FILE'])) {
                        save_text($copy_file, $section_text['FILE']);
                }
+
                $temp_filenames = array(
                        'file' => $copy_file,
                        'diff' => $diff_filename,
@@ -1240,16 +1296,19 @@
        @unlink($test_clean);
 
        // Reset environment from any previous test.
-       $env['REDIRECT_STATUS']='';
-       $env['QUERY_STRING']='';
-       $env['PATH_TRANSLATED']='';
-       $env['SCRIPT_FILENAME']='';
-       $env['REQUEST_METHOD']='';
-       $env['CONTENT_TYPE']='';
-       $env['CONTENT_LENGTH']='';
+       $env['REDIRECT_STATUS'] = '';
+       $env['QUERY_STRING']    = '';
+       $env['PATH_TRANSLATED'] = '';
+       $env['SCRIPT_FILENAME'] = '';
+       $env['REQUEST_METHOD']  = '';
+       $env['CONTENT_TYPE']    = '';
+       $env['CONTENT_LENGTH']  = '';
+
        if (!empty($section_text['ENV'])) {
+
                foreach(explode("\n", trim($section_text['ENV'])) as $e) {
-                       $e = explode('=',trim($e),2);
+                       $e = explode('=', trim($e), 2);
+
                        if (!empty($e[0]) && isset($e[1])) {
                                $env[$e[0]] = $e[1];
                        }
@@ -1270,12 +1329,15 @@
                }
                settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), 
$ini_settings);
        }
+
        settings2params($ini_settings);
 
        // Check if test should be skipped.
        $info = '';
        $warn = false;
+
        if (array_key_exists('SKIPIF', $section_text)) {
+
                if (trim($section_text['SKIPIF'])) {
                        show_file_block('skip', $section_text['SKIPIF']);
                        save_text($test_skipif, $section_text['SKIPIF'], 
$temp_skipif);
@@ -1367,8 +1429,13 @@
                        );
                }
        }
+
        if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) {
-               if (is_array($org_file)) $file = $org_file[0];
+
+               if (is_array($org_file)) {
+                       $file = $org_file[0];
+               }
+
                $bork_info = "Redirected test did not contain redirection info";
                show_result("BORK", $bork_info, '', $temp_filenames);
                $PHP_FAILED_TESTS['BORKED'][] = array (
@@ -1386,6 +1453,7 @@
        // We've satisfied the preconditions - run the test!
        show_file_block('php', $section_text['FILE'], 'TEST');
        save_text($test_file, $section_text['FILE'], $temp_file);
+
        if (array_key_exists('GET', $section_text)) {
                $query_string = trim($section_text['GET']);
        } else {
@@ -1403,20 +1471,27 @@
                $env['HTTP_COOKIE'] = '';
        }
 
-       $args = isset($section_text['ARGS']) ? ' -- '.$section_text['ARGS'] : 
'';
+       $args = isset($section_text['ARGS']) ? ' -- ' . $section_text['ARGS'] : 
'';
 
        if (array_key_exists('POST_RAW', $section_text) && 
!empty($section_text['POST_RAW'])) {
+
                $post = trim($section_text['POST_RAW']);
                $raw_lines = explode("\n", $post);
 
                $request = '';
                $started = false;
+
                foreach ($raw_lines as $line) {
+
                        if (empty($env['CONTENT_TYPE']) && 
preg_match('/^Content-Type:(.*)/i', $line, $res)) {
                                $env['CONTENT_TYPE'] = trim(str_replace("\r", 
'', $res[1]));
                                continue;
                        }
-                       if ($started) $request .= "\n";
+
+                       if ($started) {
+                               $request .= "\n";
+                       }
+
                        $started = true;
                        $request .= $line;
                }
@@ -1427,8 +1502,10 @@
                if (empty($request)) {
                        return 'BORKED';
                }
+
                save_text($tmp_post, $request);
                $cmd = "$php$pass_options$ini_settings -f \"$test_file\" 2>&1 < 
$tmp_post";
+
        } elseif (array_key_exists('POST', $section_text) && 
!empty($section_text['POST'])) {
 
                $post = trim($section_text['POST']);
@@ -1461,12 +1538,14 @@
 
        if ($leak_check) {
                $env['USE_ZEND_ALLOC'] = '0';
+
                if ($valgrind_version >= 330) {
                        /* valgrind 3.3.0+ doesn't have --log-file-exactly 
option */
                        $cmd = "valgrind -q --tool=memcheck 
--trace-children=yes --log-file=$memcheck_filename $cmd";
                } else {
                        $cmd = "valgrind -q --tool=memcheck 
--trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
                }
+
        } else {
                $env['USE_ZEND_ALLOC'] = '1';
        }
@@ -1486,17 +1565,20 @@
        $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? 
$section_text['STDIN'] : null);
 
        if (array_key_exists('CLEAN', $section_text) && (!$no_clean || 
$cfg['keep']['clean'])) {
+
                if (trim($section_text['CLEAN'])) {
                        show_file_block('clean', $section_text['CLEAN']);
                        save_text($test_clean, trim($section_text['CLEAN']), 
$temp_clean);
+
                        if (!$no_clean) {
                                $clean_params = array();
-                               settings2array($ini_overwrites,$clean_params);
+                               settings2array($ini_overwrites, $clean_params);
                                settings2params($clean_params);
                                $extra = substr(PHP_OS, 0, 3) !== "WIN" ?
                                        "unset REQUEST_METHOD; unset 
QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset 
REQUEST_METHOD;": "";
                                system_with_timeout("$extra $php $pass_options 
-q $clean_params $test_clean", $env);
                        }
+
                        if (!$cfg['keep']['clean']) {
                                @unlink($test_clean);
                        }
@@ -1510,6 +1592,7 @@
 
        if ($leak_check) { // leak check
                $leaked = @filesize($memcheck_filename) > 0;
+
                if (!$leaked) {
                        @unlink($memcheck_filename);
                }
@@ -1520,12 +1603,14 @@
 
        /* when using CGI, strip the headers from the output */
        $headers = "";
+
        if (isset($old_php) && preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $out, 
$match)) {
                $output = trim($match[2]);
-               $rh = preg_split("/[\n\r]+/",$match[1]);
+               $rh = preg_split("/[\n\r]+/", $match[1]);
                $headers = array();
+
                foreach ($rh as $line) {
-                       if (strpos($line, ':')!==false) {
+                       if (strpos($line, ':') !== false) {
                                $line = explode(':', $line, 2);
                                $headers[trim($line[0])] = trim($line[1]);
                        }
@@ -1533,10 +1618,12 @@
        }
 
        $failed_headers = false;
+
        if (isset($section_text['EXPECTHEADERS'])) {
                $want = array();
                $wanted_headers = array();
-               $lines = preg_split("/[\n\r]+/",$section_text['EXPECTHEADERS']);
+               $lines = preg_split("/[\n\r]+/", 
$section_text['EXPECTHEADERS']);
+
                foreach($lines as $line) {
                        if (strpos($line, ':') !== false) {
                                $line = explode(':', $line, 2);
@@ -1544,18 +1631,23 @@
                                $wanted_headers[] = trim($line[0]) . ': ' . 
trim($line[1]);
                        }
                }
+
                $org_headers = $headers;
                $headers = array();
                $output_headers = array();
+
                foreach($want as $k => $v) {
+
                        if (isset($org_headers[$k])) {
                                $headers = $org_headers[$k];
                                $output_headers[] = $k . ': ' . 
$org_headers[$k];
                        }
+
                        if (!isset($org_headers[$k]) || $org_headers[$k] != $v) 
{
                                $failed_headers = true;
                        }
                }
+
                ksort($wanted_headers);
                $wanted_headers = join("\n", $wanted_headers);
                ksort($output_headers);
@@ -1563,14 +1655,18 @@
        }
 
        show_file_block('out', $output);
+
        if (isset($section_text['EXPECTF']) || 
isset($section_text['EXPECTREGEX'])) {
+
                if (isset($section_text['EXPECTF'])) {
                        $wanted = trim($section_text['EXPECTF']);
                } else {
                        $wanted = trim($section_text['EXPECTREGEX']);
                }
+
                show_file_block('exp', $wanted);
-               $wanted_re = preg_replace('/\r\n/',"\n",$wanted);
+               $wanted_re = preg_replace('/\r\n/', "\n", $wanted);
+
                if (isset($section_text['EXPECTF'])) {
                        $wanted_re = preg_quote($wanted_re, '/');
                        // Stick to basics
@@ -1629,6 +1725,7 @@
                $passed = false;
                $wanted = $wanted_headers . "\n--HEADERS--\n" . $wanted;
                $output = $output_headers . "\n--HEADERS--\n" . $output;
+
                if (isset($wanted_re)) {
                        $wanted_re = preg_quote($wanted_headers . 
"\n--HEADERS--\n", '/') . $wanted_re;
                }
@@ -1698,18 +1795,19 @@
        return $restype[0].'ED';
 }
 
-function comp_line($l1,$l2,$is_reg)
+function comp_line($l1, $l2, $is_reg)
 {
        if ($is_reg) {
-               return preg_match('/^'.$l1.'$/s', $l2);
+               return preg_match("/^$l1$/s", $l2);
        } else {
                return !strcmp($l1, $l2);
        }
 }
 
-function count_array_diff($ar1,$ar2,$is_reg,$w,$idx1,$idx2,$cnt1,$cnt2,$steps)
+function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, $cnt2, 
$steps)
 {
        $equal = 0;
+
        while ($idx1 < $cnt1 && $idx2 < $cnt2 && comp_line($ar1[$idx1], 
$ar2[$idx2], $is_reg)) {
                $idx1++;
                $idx2++;
@@ -1719,94 +1817,109 @@
        if (--$steps > 0) {
                $eq1 = 0;
                $st = $steps / 2;
-               for ($ofs1 = $idx1+1; $ofs1 < $cnt1 && $st-- > 0; $ofs1++) {
-                       $eq = 
count_array_diff($ar1,$ar2,$is_reg,$w,$ofs1,$idx2,$cnt1,$cnt2,$st);
+
+               for ($ofs1 = $idx1 + 1; $ofs1 < $cnt1 && $st-- > 0; $ofs1++) {
+                       $eq = count_array_diff($ar1, $ar2, $is_reg, $w, $ofs1, 
$idx2, $cnt1, $cnt2, $st);
+
                        if ($eq > $eq1) {
                                $eq1 = $eq;
                        }
                }
+
                $eq2 = 0;
                $st = $steps;
-               for ($ofs2 = $idx2+1; $ofs2 < $cnt2 && $st-- > 0; $ofs2++) {
-                       $eq = 
count_array_diff($ar1,$ar2,$is_reg,$w,$idx1,$ofs2,$cnt1,$cnt2,$st);
+
+               for ($ofs2 = $idx2 + 1; $ofs2 < $cnt2 && $st-- > 0; $ofs2++) {
+                       $eq = count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, 
$ofs2, $cnt1, $cnt2, $st);
                        if ($eq > $eq2) {
                                $eq2 = $eq;
                        }
                }
+
                if ($eq1 > $eq2) {
                        $equal += $eq1;
                } else if ($eq2 > 0) {
                        $equal += $eq2;
                }
        }
+
        return $equal;
 }
 
-function generate_array_diff($ar1,$ar2,$is_reg,$w)
+function generate_array_diff($ar1, $ar2, $is_reg, $w)
 {
        $idx1 = 0; $ofs1 = 0; $cnt1 = count($ar1);
        $idx2 = 0; $ofs2 = 0; $cnt2 = count($ar2);
        $diff = array();
        $old1 = array();
        $old2 = array();
-       
+
        while ($idx1 < $cnt1 && $idx2 < $cnt2) {
+
                if (comp_line($ar1[$idx1], $ar2[$idx2], $is_reg)) {
                        $idx1++;
                        $idx2++;
                        continue;
                } else {
-                       $c1 = 
count_array_diff($ar1,$ar2,$is_reg,$w,$idx1+1,$idx2,$cnt1,$cnt2,10);
-                       $c2 = 
count_array_diff($ar1,$ar2,$is_reg,$w,$idx1,$idx2+1,$cnt1,$cnt2,10);
+
+                       $c1 = count_array_diff($ar1, $ar2, $is_reg, $w, 
$idx1+1, $idx2, $cnt1, $cnt2, 10);
+                       $c2 = count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, 
$idx2+1, $cnt1,  $cnt2, 10);
+
                        if ($c1 > $c2) {
-                               $old1[$idx1] = sprintf("%03d- ", 
$idx1+1).$w[$idx1++];
+                               $old1[$idx1] = sprintf("%03d- ", $idx1+1) . 
$w[$idx1++];
                                $last = 1;
                        } else if ($c2 > 0) {
-                               $old2[$idx2] = sprintf("%03d+ ", 
$idx2+1).$ar2[$idx2++];
+                               $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . 
$ar2[$idx2++];
                                $last = 2;
                        } else {
-                               $old1[$idx1] = sprintf("%03d- ", 
$idx1+1).$w[$idx1++];
-                               $old2[$idx2] = sprintf("%03d+ ", 
$idx2+1).$ar2[$idx2++];
+                               $old1[$idx1] = sprintf("%03d- ", $idx1+1) . 
$w[$idx1++];
+                               $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . 
$ar2[$idx2++];
                        }
                }
        }
-       
+
        reset($old1); $k1 = key($old1); $l1 = -2;
-       reset($old2); $k2 = key($old2); $l2 = -2;  
-       while ($k1 !== NULL || $k2 !== NULL) {
-               if ($k1 == $l1+1 || $k2 === NULL) {
+       reset($old2); $k2 = key($old2); $l2 = -2;
+
+       while ($k1 !== null || $k2 !== null) {
+
+               if ($k1 == $l1 + 1 || $k2 === null) {
                        $l1 = $k1;
                        $diff[] = current($old1);
-                       $k1 = next($old1) ? key($old1) : NULL;
-               } else if ($k2 == $l2+1 || $k1 === NULL) {
+                       $k1 = next($old1) ? key($old1) : null;
+               } else if ($k2 == $l2 + 1 || $k1 === null) {
                        $l2 = $k2;
                        $diff[] = current($old2);
-                       $k2 = next($old2) ? key($old2) : NULL;
+                       $k2 = next($old2) ? key($old2) : null;
                } else if ($k1 < $k2) {
                        $l1 = $k1;
                        $diff[] = current($old1);
-                       $k1 = next($old1) ? key($old1) : NULL;
+                       $k1 = next($old1) ? key($old1) : null;
                } else {
                        $l2 = $k2;
                        $diff[] = current($old2);
-                       $k2 = next($old2) ? key($old2) : NULL;
+                       $k2 = next($old2) ? key($old2) : null;
                }
        }
+
        while ($idx1 < $cnt1) {
-               $diff[] = sprintf("%03d- ", $idx1+1).$w[$idx1++];
+               $diff[] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
        }
+
        while ($idx2 < $cnt2) {
-               $diff[] = sprintf("%03d+ ", $idx2+1).$ar2[$idx2++];
+               $diff[] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
        }
+
        return $diff;
 }
 
-function generate_diff($wanted,$wanted_re,$output)
+function generate_diff($wanted, $wanted_re, $output)
 {
        $w = explode("\n", $wanted);
        $o = explode("\n", $output);
        $r = is_null($wanted_re) ? $w : explode("\n", $wanted_re);
-       $diff = generate_array_diff($r,$o,!is_null($wanted_re),$w);
+       $diff = generate_array_diff($r, $o, !is_null($wanted_re), $w);
+
        return implode("\r\n", $diff);
 }
 
@@ -1819,15 +1932,20 @@
 function settings2array($settings, &$ini_settings)
 {
        foreach($settings as $setting) {
-               if (strpos($setting, '=')!==false) {
+
+               if (strpos($setting, '=') !== false) {
                        $setting = explode("=", $setting, 2);
                        $name = trim(strtolower($setting[0]));
                        $value = trim($setting[1]);
+
                        if ($name == 'extension') {
+
                                if (!isset($ini_settings[$name])) {
                                        $ini_settings[$name] = array();
                                }
+
                                $ini_settings[$name][] = $value;
+
                        } else {
                                $ini_settings[$name] = $value;
                        }
@@ -1838,7 +1956,9 @@
 function settings2params(&$ini_settings)
 {
        $settings = '';
+
        foreach($ini_settings as $name => $value) {
+
                if (is_array($value)) {
                        foreach($value as $val) {
                                $val = addslashes($val);
@@ -1849,6 +1969,7 @@
                        $settings .= " -d \"$name=$value\"";
                }
        }
+
        $ini_settings = $settings;
 }
 
@@ -1874,6 +1995,7 @@
        global $exts_skipped, $exts_tested, $n_total, $sum_results, 
$percent_results, $end_time, $start_time, $failed_test_summary, 
$PHP_FAILED_TESTS, $leak_check;
 
        $x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['BORKED'];
+
        if ($x_total) {
                $x_warned = (100.0 * $sum_results['WARNED']) / $x_total;
                $x_failed = (100.0 * $sum_results['FAILED']) / $x_total;
@@ -1927,9 +2049,10 @@
                foreach ($PHP_FAILED_TESTS['BORKED'] as $failed_test_data) {
                        $failed_test_summary .= $failed_test_data['info'] . 
"\n";
                }
+
                $failed_test_summary .=  
"=====================================================================\n";
        }
-       
+
        if (count($PHP_FAILED_TESTS['FAILED'])) {
                $failed_test_summary .= "
 =====================================================================
@@ -1962,6 +2085,7 @@
                foreach ($PHP_FAILED_TESTS['LEAKED'] as $failed_test_data) {
                        $failed_test_summary .= $failed_test_data['test_name'] 
. $failed_test_data['info'] . "\n";
                }
+
                $failed_test_summary .=  
"=====================================================================\n";
        }
        
@@ -1978,11 +2102,11 @@
 {
        global $html_output, $html_file;
 
-       if ($html_output)
-       {
+       if ($html_output) {
                fwrite($html_file, "<h2>Time Start: " . @date('Y-m-d H:i:s', 
$start_time) . "</h2>\n");
                fwrite($html_file, "<table>\n");
        }
+
        echo "TIME START " . @date('Y-m-d H:i:s', $start_time) . 
"\n=====================================================================\n";
 }
 
@@ -1990,11 +2114,11 @@
 {
        global $html_output, $html_file;
 
-       if ($html_output)
-       {
+       if ($html_output) {
                fwrite($html_file, "</table>\n");
                fwrite($html_file, "<h2>Time End: " . @date('Y-m-d H:i:s', 
$end_time) . "</h2>\n");
        }
+
        echo 
"=====================================================================\nTIME 
END " . @date('Y-m-d H:i:s', $end_time) . "\n";
 }
 
@@ -2002,10 +2126,10 @@
 {
        global $html_output, $html_file;
 
-       if ($html_output)
-       {
+       if ($html_output) {
                fwrite($html_file, "<hr/>\n" . get_summary(true, true));
        }
+
        echo get_summary(true, false);
 }
 
@@ -2013,10 +2137,10 @@
 {
        global $html_output, $html_file;
 
-       if ($html_output)
-       {
+       if ($html_output) {
                fwrite($html_file, "<tr><td colspan='3'>---&gt; $tests ($tested 
[$tested_file]) begin</td></tr>\n");
        }
+
        echo "---> $tests ($tested [$tested_file]) begin\n";
 }
 
@@ -2024,10 +2148,10 @@
 {
        global $html_output, $html_file;
 
-       if ($html_output)
-       {
+       if ($html_output) {
                fwrite($html_file, "<tr><td colspan='3'>---&gt; $tests ($tested 
[$tested_file]) done</td></tr>\n");
        }
+
        echo "---> $tests ($tested [$tested_file]) done\n";
 }
 
@@ -2045,33 +2169,40 @@
 
        echo "$result $tested [$tested_file] $extra\n";
 
-       if ($html_output)
-       {
+       if ($html_output) {
+
                if (isset($temp_filenames['file']) && 
@file_exists($temp_filenames['file'])) {
                        $url = str_replace($temp_target, $temp_urlbase, 
$temp_filenames['file']);
                        $tested = "<a href='$url'>$tested</a>";
                }
+
                if (isset($temp_filenames['skip']) && 
@file_exists($temp_filenames['skip'])) {
+
                        if (empty($extra)) {
                                $extra = "skipif";
                        }
+
                        $url = str_replace($temp_target, $temp_urlbase, 
$temp_filenames['skip']);
                        $extra = "<a href='$url'>$extra</a>";
+
                } else if (empty($extra)) {
                        $extra = "&nbsp;";
                }
+
                if (isset($temp_filenames['diff']) && 
@file_exists($temp_filenames['diff'])) {
                        $url = str_replace($temp_target, $temp_urlbase, 
$temp_filenames['diff']);
                        $diff = "<a href='$url'>diff</a>";
                } else {
                        $diff = "&nbsp;";
                }
+
                if (isset($temp_filenames['mem']) && 
@file_exists($temp_filenames['mem'])) {
                        $url = str_replace($temp_target, $temp_urlbase, 
$temp_filenames['mem']);
                        $mem = "<a href='$url'>leaks</a>";
                } else {
                        $mem = "&nbsp;";
                }
+
                fwrite($html_file, 
                        "<tr>" .
                        "<td>$result</td>" .

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to