helly Wed Jan 4 15:07:49 2006 UTC
Modified files:
/php-src run-tests.php
Log:
- Add CLEAN section which contains optional cleanup code executed even when
the test fails and which can be prevented by --no-clean switch
http://cvs.php.net/viewcvs.cgi/php-src/run-tests.php?r1=1.270&r2=1.271&diff_format=u
Index: php-src/run-tests.php
diff -u php-src/run-tests.php:1.270 php-src/run-tests.php:1.271
--- php-src/run-tests.php:1.270 Sun Jan 1 13:09:48 2006
+++ php-src/run-tests.php Wed Jan 4 15:07:49 2006
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: run-tests.php,v 1.270 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: run-tests.php,v 1.271 2006/01/04 15:07:49 helly 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
@@ -247,9 +247,10 @@
$temp_target = null;
$temp_urlbase = null;
$conf_passed = null;
+$no_clean = false;
$cfgtypes = array('show', 'keep');
-$cfgfiles = array('skip', 'php');
+$cfgfiles = array('skip', 'php', 'clean');
$cfg = array();
foreach($cfgtypes as $type) {
$cfg[$type] = array();
@@ -322,6 +323,9 @@
case '--keep-php':
$cfg['keep']['php'] = true;
break;
+ case '--keep-clean':
+ $cfg['keep']['clean'] = true;
+ break;
//case 'l'
case 'm':
$leak_check = true;
@@ -336,6 +340,9 @@
$unicode_and_native = false;
$unicode_testing = false;
break;
+ case '--no-clean':
+ $no_clean = true;
+ break;
case 'q':
putenv('NO_INTERACTION=1');
break;
@@ -355,6 +362,9 @@
case '--show-php':
$cfg['show']['php'] = true;
break;
+ case '--show-clean':
+ $cfg['show']['clean'] = true;
+ break;
case '--temp-source':
$temp_source = $argv[++$i];
break;
@@ -395,7 +405,7 @@
$html_output = is_resource($html_file);
break;
case '--version':
- echo '$Revision: 1.270 $'."\n";
+ echo '$Revision: 1.271 $'."\n";
exit(1);
default:
echo "Illegal switch specified!\n";
@@ -454,11 +464,14 @@
to your source files and <tdir> some pach in your web page
hierarchy with <url> pointing to <tdir>.
- --keep-[all|php|skip]
- Do not delete 'all' files, 'php' test file, 'skip' file.
+ --keep-[all|php|skip|clean]
+ Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
+ file.
- --show-[all|php|skip]
- Show 'all' files, 'php' test file, 'skip' file.
+ --show-[all|php|skip|clean]
+ Show 'all' files, 'php' test file, 'skip' or 'clean' file.
+
+ --no-clean Do not execute clean section if any.
HELP;
exit(1);
@@ -924,6 +937,7 @@
global $log_format, $info_params, $ini_overwrites, $cwd,
$PHP_FAILED_TESTS;
global $pass_options, $DETAILED, $IN_REDIRECT, $test_cnt, $test_idx;
global $leak_check, $temp_source, $temp_target, $cfg, $environment;
+ global $no_clean;
global $unicode_and_native;
$temp_filenames = null;
@@ -1062,14 +1076,17 @@
$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'mem';
$temp_file = $temp_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'php';
$test_file = $test_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'php';
- $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'skip';
- $test_skipif = $test_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'skip';
+ $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'skip.php';
+ $test_skipif = $test_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'skip.php';
+ $temp_clean = $temp_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'clean.php';
+ $test_clean = $test_dir . DIRECTORY_SEPARATOR .
basename($file,'phpt').$pu.'clean.php';
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
$tmp_relative_file = str_replace(dirname(__FILE__).DIRECTORY_SEPARATOR,
'', $test_file) . 't';
if ($temp_source && $temp_target) {
- $temp_skipif .= '.phps';
- $temp_file .= '.phps';
+ $temp_skipif .= 's';
+ $temp_file .= 's';
+ $temp_clean .= 's';
$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));
@@ -1085,7 +1102,8 @@
'out' => $output_filename,
'mem' => $memcheck_filename,
'php' => $temp_file,
- 'skip' => $temp_skipif);
+ 'skip' => $temp_skipif,
+ 'clean'=> $temp_clean);
}
if (is_array($IN_REDIRECT)) {
@@ -1105,6 +1123,8 @@
@unlink($temp_skipif);
@unlink($test_skipif);
@unlink($tmp_post);
+ @unlink($temp_clean);
+ @unlink($test_clean);
// Reset environment from any previous test.
$env['REDIRECT_STATUS']='';
@@ -1141,7 +1161,9 @@
$extra = substr(PHP_OS, 0, 3) !== "WIN" ?
"unset REQUEST_METHOD; unset QUERY_STRING;
unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": "";
$output = system_with_timeout("$extra $php -q
$skipif_params $test_skipif", $env);
- @unlink($test_skipif);
+ if (!$cfg['keep']['skip']) {
+ @unlink($test_skipif);
+ }
if (!strncasecmp('skip', trim($output), 4)) {
$reason = (eregi("^skip[[:space:]]*(.+)\$",
trim($output))) ? eregi_replace("^skip[[:space:]]*(.+)\$", "\\1",
trim($output)) : FALSE;
if ($reason) {
@@ -1332,6 +1354,28 @@
$out = system_with_timeout($cmd, $env);
+ if (array_key_exists('CLEAN', $section_text) && (!$no_clean ||
$cfg['keep']['clean'])) {
+ if (trim($section_text['CLEAN'])) {
+ if ($cfg['show']['clean']) {
+ echo "\n========CLEAN=======\n";
+ echo $section_text['CLEAN'];
+ echo "========DONE========\n";
+ }
+ save_text($test_clean, trim($section_text['CLEAN']),
$temp_clean);
+ if (!$no_clean) {
+ $clean_params = array();
+ 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 -q
$clean_params $clean_skipif", $env);
+ }
+ if (!$cfg['keep']['clean']) {
+ @unlink($test_clean);
+ }
+ }
+ }
+
@unlink($tmp_post);
$leaked = false;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php