iliaa Tue Dec 6 21:01:59 2005 EDT Modified files: (Branch: PHP_5_1) /php-src run-tests.php Log: Fixed filename picker. Various modernizations of the script. http://cvs.php.net/diff.php/php-src/run-tests.php?r1=1.226.2.4&r2=1.226.2.5&ty=u Index: php-src/run-tests.php diff -u php-src/run-tests.php:1.226.2.4 php-src/run-tests.php:1.226.2.5 --- php-src/run-tests.php:1.226.2.4 Tue Dec 6 19:03:46 2005 +++ php-src/run-tests.php Tue Dec 6 21:01:58 2005 @@ -23,7 +23,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: run-tests.php,v 1.226.2.4 2005/12/07 00:03:46 helly Exp $ */ +/* $Id: run-tests.php,v 1.226.2.5 2005/12/07 02:01:58 iliaa 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 @@ -223,8 +223,11 @@ $pass_option_n = false; $pass_options = ''; -$compression = 0; -$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . ( $compression ? '.txt.gz' : '.txt' ); +$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; @@ -315,7 +318,7 @@ $html_output = is_resource($html_file); break; case '--version': - echo "$Id: run-tests.php,v 1.226.2.4 2005/12/07 00:03:46 helly Exp $\n"; + echo "$Id: run-tests.php,v 1.226.2.5 2005/12/07 02:01:58 iliaa Exp $\n"; exit(1); default: echo "Illegal switch specified!\n"; @@ -831,7 +834,6 @@ $line = fgets($fp); // Match the beginning of a section. - // UTODO changed to use preg, because ereg was crapping out if (preg_match('/^--([A-Z]+)--/',$line,$r)) { $section = $r[1]; $section_text[$section] = ''; @@ -857,7 +859,7 @@ $borked = true; } if (@count($section_text['FILEEOF']) == 1) { - $section_text['FILE'] = preg_replace('/[\r\n]+$/', '', $section_text['FILEEOF']); + $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']); unset($section_text['FILEEOF']); } if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) { @@ -898,13 +900,13 @@ $tmp = realpath(dirname($file)); } - $diff_filename = $tmp . DIRECTORY_SEPARATOR . basename($file).'diff'; - $log_filename = $tmp . DIRECTORY_SEPARATOR . basename($file).'log'; - $exp_filename = $tmp . DIRECTORY_SEPARATOR . basename($file).'exp'; - $output_filename = $tmp . DIRECTORY_SEPARATOR . basename($file).'out'; - $memcheck_filename = $tmp . DIRECTORY_SEPARATOR . basename($file).'mem'; - $tmp_file = $tmp . DIRECTORY_SEPARATOR . basename($file).'php'; - $tmp_skipif = $tmp . DIRECTORY_SEPARATOR . basename($file).'skip'; + $diff_filename = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'diff'; + $log_filename = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'log'; + $exp_filename = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'exp'; + $output_filename = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'out'; + $memcheck_filename = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'mem'; + $tmp_file = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'php'; + $tmp_skipif = $tmp . DIRECTORY_SEPARATOR . basename($file,'phpt').'skip'; $tmp_post = $tmp . DIRECTORY_SEPARATOR . uniqid('/phpt.'); $tmp_relative_file = str_replace(dirname(__FILE__).DIRECTORY_SEPARATOR, '', $tmp_file) . 't'; @@ -946,7 +948,7 @@ "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": ""; $output = system_with_timeout("$extra $php -q $skipif_params $tmp_skipif"); @unlink($tmp_skipif); - if (eregi("^skip", trim($output))) { + if (!strncasecmp('skip', trim($output), 4)) { $reason = (eregi("^skip[[:space:]]*(.+)\$", trim($output))) ? eregi_replace("^skip[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE; if ($reason) { show_result("SKIP", $tested, $file, "reason: $reason"); @@ -959,13 +961,13 @@ @unlink($tmp_skipif); return 'SKIPPED'; } - if (eregi("^info", trim($output))) { + if (!strncasecmp('info', trim($output), 4)) { $reason = (ereg("^info[[:space:]]*(.+)\$", trim($output))) ? ereg_replace("^info[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE; if ($reason) { $info = " (info: $reason)"; } } - if (eregi("^warn", trim($output))) { + if (!strncasecmp('warn', trim($output), 4)) { $reason = (ereg("^warn[[:space:]]*(.+)\$", trim($output))) ? ereg_replace("^warn[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE; if ($reason) { $warn = true; /* only if there is a reason */ @@ -1044,6 +1046,9 @@ // Any special ini settings // these may overwrite the test defaults... if (array_key_exists('INI', $section_text)) { + if (strpos($section_text['INI'], '{PWD}') !== false) { + $section_text['INI'] = str_replace('{PWD}', dirname($file), $section_text['INI']); + } settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings); } settings2params($ini_settings); @@ -1132,8 +1137,7 @@ } // Does the output match what is expected? - $output = trim($out); - $output = preg_replace('/\r\n/',"\n",$output); + $output = str_replace("\r\n", "\n", trim($out)); /* when using CGI, strip the headers from the output */ if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) { @@ -1215,36 +1219,28 @@ if (!$passed) { // write .exp if (strpos($log_format,'E') !== FALSE) { - $log = fopen($exp_filename,'wt') or error("Cannot create test log - $exp_filename"); - fwrite($log,$wanted); - fclose($log); + file_put_contents($exp_filename, $wanted) or error("Cannot create test log - $exp_filename"); } // write .out if (strpos($log_format,'O') !== FALSE) { - $log = fopen($output_filename,'wt') or error("Cannot create test log - $output_filename"); - fwrite($log,$output); - fclose($log); + file_put_contents($output_filename, $output) or error("Cannot create test log - $output_filename"); } // write .diff if (strpos($log_format,'D') !== FALSE) { - $log = fopen($diff_filename,'wt') or error("Cannot create test log - $diff_filename"); - fwrite($log, generate_diff($wanted,$wanted_re,$output)); - fclose($log); + file_put_contents($diff_filename, generate_diff($wanted,$wanted_re,$output)) or error("Cannot create test log - $diff_filename"); } // write .log if (strpos($log_format,'L') !== FALSE) { - $log = fopen($log_filename,'wt') or error("Cannot create test log - $log_filename"); - fwrite($log," + file_put_contents($log_filename, " ---- EXPECTED OUTPUT $wanted ---- ACTUAL OUTPUT $output ---- FAILED -"); - fclose($log); +") or error("Cannot create test log - $log_filename"); error_report($file,$log_filename,$tested); } }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php