summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
commit0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch)
treed5107db4b7369603ac7c753829e8972ee74949f7 /run-tests.php
parentce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff)
downloadphp-upstream/5.1.2.tar.gz
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php922
1 files changed, 672 insertions, 250 deletions
diff --git a/run-tests.php b/run-tests.php
index cd28130e0..25ceef348 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -3,12 +3,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -23,12 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: run-tests.php,v 1.226.2.3 2005/10/06 09:42:17 helly Exp $ */
-
-/*
- * TODO:
- * - do not test PEAR components if base class and/or component class cannot be instanciated
- */
+/* $Id: run-tests.php,v 1.226.2.27 2006/01/04 15:17:41 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
@@ -102,6 +97,8 @@ if (ini_get('safe_mode')) {
SAFE_MODE_WARNING;
}
+$environment = isset($_ENV) ? $_ENV : array();
+
// Don't ever guess at the PHP executable location.
// Require the explicit specification.
// Otherwise we could end up testing the wrong file!
@@ -112,10 +109,17 @@ if (getenv('TEST_PHP_EXECUTABLE')) {
$php = $cwd.'/sapi/cli/php';
putenv("TEST_PHP_EXECUTABLE=$php");
}
+ $environment['TEST_PHP_EXECUTABLE'] = $php;
}
-if (empty($php) || !file_exists($php)) {
- error("environment variable TEST_PHP_EXECUTABLE must be set to specify PHP executable!");
+if ($argc !=2 || ($argv[1] != '-h' && $argv[1] != '-help' && $argv != '--help'))
+{
+ if (empty($php) || !file_exists($php)) {
+ error("environment variable TEST_PHP_EXECUTABLE must be set to specify PHP executable!");
+ }
+ if (function_exists('is_executable') && !@is_executable($php)) {
+ error("invalid PHP executable specified by TEST_PHP_EXECUTABLE = " . $php);
+ }
}
if (getenv('TEST_PHP_LOG_FORMAT')) {
@@ -124,10 +128,6 @@ if (getenv('TEST_PHP_LOG_FORMAT')) {
$log_format = 'LEOD';
}
-if (function_exists('is_executable') && !@is_executable($php)) {
- error("invalid PHP executable specified by TEST_PHP_EXECUTABLE = " . $php);
-}
-
// Check whether a detailed log is wanted.
if (getenv('TEST_PHP_DETAILED')) {
$DETAILED = getenv('TEST_PHP_DETAILED');
@@ -164,7 +164,7 @@ $ini_overwrites = array(
'magic_quotes_runtime=0',
);
-function write_information()
+function write_information($show_html)
{
global $cwd, $php, $php_info, $user_tests, $ini_overwrites, $pass_options;
@@ -221,16 +221,59 @@ Extra dirs : ";
$test_files = array();
$redir_tests = array();
$test_results = array();
-$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array());
+$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array());
// If parameters given assume they represent selected tests to run.
$failed_tests_file= false;
$pass_option_n = false;
$pass_options = '';
+
+$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;
+$html_file = null;
+$temp_source = null;
+$temp_target = null;
+$temp_urlbase = null;
+$conf_passed = null;
+$no_clean = false;
+
+$cfgtypes = array('show', 'keep');
+$cfgfiles = array('skip', 'php', 'clean');
+$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))
+ {
+ $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++) {
- if (substr($argv[$i],0,1) == '-') {
- $switch = strtolower(substr($argv[$i],1,1));
+ $is_switch = false;
+ $switch = substr($argv[$i],1,1);
+ $repeat = substr($argv[$i],0,1) == '-';
+ while ($repeat) {
+ $repeat = false;
+ if (!$is_switch) {
+ $switch = substr($argv[$i],1,1);
+ }
+ $is_switch = true;
switch($switch) {
case 'r':
case 'l':
@@ -256,8 +299,30 @@ if (isset($argc) && $argc > 1) {
case 'a':
$failed_tests_file = fopen($argv[++$i], 'a+t');
break;
- case 'v':
- $DETAILED = true;
+ case 'c':
+ $conf_passed = $argv[++$i];
+ break;
+ case 'd':
+ $ini_overwrites[] = $argv[++$i];
+ break;
+ //case 'h'
+ case '--keep-all':
+ foreach($cfgfiles as $file) {
+ $cfg['keep'][$file] = true;
+ }
+ break;
+ case '--keep-skip':
+ $cfg['keep']['skip'] = true;
+ break;
+ case '--keep-php':
+ $cfg['keep']['php'] = true;
+ break;
+ case '--keep-clean':
+ $cfg['keep']['clean'] = true;
+ break;
+ //case 'l'
+ case 'm':
+ $leak_check = true;
break;
case 'n':
if (!$pass_option_n) {
@@ -265,14 +330,71 @@ if (isset($argc) && $argc > 1) {
}
$pass_option_n = true;
break;
- case 'd':
- $ini_overwrites[] = $argv[++$i];
+ case '--no-clean':
+ $no_clean = true;
+ break;
+ case 'q':
+ putenv('NO_INTERACTION=1');
+ break;
+ //case 'r'
+ case 's':
+ $output_file = $argv[++$i];
+ $just_save_results = true;
+ break;
+ case '--show-all':
+ foreach($cfgfiles as $file) {
+ $cfg['show'][$file] = true;
+ }
+ break;
+ case '--show-skip':
+ $cfg['show']['skip'] = true;
+ break;
+ case '--show-php':
+ $cfg['show']['php'] = true;
+ break;
+ case '--show-clean':
+ $cfg['show']['clean'] = true;
+ break;
+ case '--temp-source':
+ $temp_source = $argv[++$i];
+ break;
+ case '--temp-target':
+ $temp_target = $argv[++$i];
+ if ($temp_urlbase) {
+ $temp_urlbase = $temp_target;
+ }
+ break;
+ case '--temp-urlbase':
+ $temp_urlbase = $argv[++$i];
+ break;
+ case 'v':
+ case '--verbose':
+ $DETAILED = true;
+ break;
+ //case 'w'
+ case '-':
+ // repeat check with full switch
+ $switch = $argv[$i];
+ if ($switch != '-') {
+ $repeat = true;
+ }
+ break;
+ case '--html':
+ $html_file = @fopen($argv[++$i], 'wt');
+ $html_output = is_resource($html_file);
break;
+ case '--version':
+ echo '$Revision: 1.226.2.27 $'."\n";
+ exit(1);
default:
- echo "Illegal switch specified!\n";
- case "h":
- case "help":
- case "-help":
+ echo "Illegal switch '$switch' specified!\n";
+ if ($switch == 'u' || $switch == 'U') {
+ break;
+ }
+ // break
+ case 'h':
+ case '-help':
+ case '--help':
echo <<<HELP
Synopsis:
php run-tests.php [options] [files] [directories]
@@ -289,19 +411,49 @@ Options:
-a <file> Same as -w but append rather then truncating <file>.
+ -c <file> Look for php.ini in directory <file> or use <file> as ini.
+
-n Pass -n option to the php binary (Do not use a php.ini).
-d foo=bar Pass -d option to the php binary (Define INI entry foo
with value 'bar').
+ -m Test for memory leaks with Valgrind.
+
+ -s <file> Write output to <file>.
+
+ -q Quite, no user interaction (same as environment NO_INTERACTION).
+
+ --verbose
-v Verbose mode.
- -h <file> This Help.
+ --help
+ -h This Help.
+
+ --html <file> Generate HTML output.
+
+ --temp-source <sdir> --temp-target <tdir> [--temp-urlbase <url>]
+ Write temporary files to <tdir> by replacing <sdir> from the
+ filenames to generate with <tdir>. If --html is being used and
+ <url> given then the generated links are relative and prefixed
+ with the given url. In general you want to make <sdir> the path
+ to your source files and <tdir> some pach in your web page
+ hierarchy with <url> pointing to <tdir>.
+
+ --keep-[all|php|skip|clean]
+ Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
+ 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);
}
- } else {
+ }
+ if (!$is_switch) {
$testfile = realpath($argv[$i]);
if (is_dir($testfile)) {
find_files($testfile);
@@ -312,27 +464,43 @@ HELP;
}
}
}
+ if (strlen($conf_passed))
+ {
+ $pass_options .= " -c '$conf_passed'";
+ }
$test_files = array_unique($test_files);
$test_files = array_merge($test_files, $redir_tests);
// Run selected tests.
$test_cnt = count($test_files);
if ($test_cnt) {
- write_information();
+ write_information($html_output);
usort($test_files, "test_sort");
- echo "Running selected tests.\n";
$start_time = time();
+ if (!$html_output) {
+ echo "Running selected tests.\n";
+ } else {
+ show_start($start_time);
+ }
$test_idx = 0;
- run_all_tests($test_files);
+ run_all_tests($test_files, $environment);
$end_time = time();
+ if ($html_output) {
+ show_end($end_time);
+ }
if ($failed_tests_file) {
fclose($failed_tests_file);
}
if (count($test_files) || count($test_results)) {
- echo "
-=====================================================================";
compute_summary();
- echo get_summary(false);
+ if ($html_output) {
+ fwrite($html_file, "<hr/>\n" . get_summary(false, true));
+ }
+ echo "=====================================================================";
+ echo get_summary(false, false);
+ }
+ if ($html_output) {
+ fclose($html_file);
}
if (getenv('REPORT_EXIT_STATUS') == 1 and ereg('FAILED( |$)', implode(' ', $test_results))) {
exit(1);
@@ -341,7 +509,7 @@ HELP;
}
}
-write_information();
+write_information($html_output);
// Compile a list of all test files (*.phpt).
$test_files = array();
@@ -351,7 +519,7 @@ $exts_skipped = 0;
$ignored_by_ext = 0;
sort($exts_to_test);
$test_dirs = array('tests', 'ext');
-$optionals = array('pear', 'Zend', 'ZendEngine2');
+$optionals = array('Zend', 'ZendEngine2');
foreach($optionals as $dir) {
if (@filetype($dir) == 'dir') {
$test_dirs[] = $dir;
@@ -416,7 +584,7 @@ function test_name($name)
function test_sort($a, $b)
{
global $cwd;
-
+
$a = test_name($a);
$b = test_name($b);
@@ -433,14 +601,11 @@ $test_files = array_unique($test_files);
usort($test_files, "test_sort");
$start_time = time();
-
-echo "TIME START " . date('Y-m-d H:i:s', $start_time) . "
-=====================================================================
-";
+show_start($start_time);
$test_cnt = count($test_files);
$test_idx = 0;
-run_all_tests($test_files);
+run_all_tests($test_files, $environment);
$end_time = time();
if ($failed_tests_file) {
fclose($failed_tests_file);
@@ -455,12 +620,12 @@ if (0 == count($test_results)) {
compute_summary();
-echo "
-=====================================================================
-TIME END " . date('Y-m-d H:i:s', $end_time);
+show_end($end_time);
+show_summary();
-$summary = get_summary(true);
-echo $summary;
+if ($html_output) {
+ fclose($html_file);
+}
define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
@@ -475,7 +640,8 @@ if (!getenv('NO_INTERACTION')) {
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 || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
/*
* Collect information about the host system for our report
@@ -483,7 +649,10 @@ if (!getenv('NO_INTERACTION')) {
* Make an archive of all the failed tests
* Send an email
*/
-
+ 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): ";
@@ -496,7 +665,7 @@ if (!getenv('NO_INTERACTION')) {
$sep = "\n" . str_repeat('=', 80) . "\n";
$failed_tests_data .= $failed_test_summary . "\n";
- $failed_tests_data .= $summary . "\n";
+ $failed_tests_data .= get_summary(true, false) . "\n";
if ($sum_results['FAILED']) {
foreach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {
@@ -556,14 +725,11 @@ if (!getenv('NO_INTERACTION')) {
$failed_tests_data .= $sep . "PHPINFO" . $sep;
$failed_tests_data .= shell_exec($php.' -dhtml_errors=0 -i');
- $compression = 0;
-
if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status)) {
- $output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . ( $compression ? '.txt.gz' : '.txt' );
file_put_contents($output_file, $failed_tests_data);
if (!$just_save_results) {
- echo "\nThe test script was unable to automatically send the report to PHP's QA Team\n";
+ 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";
@@ -577,6 +743,7 @@ if (!getenv('NO_INTERACTION')) {
if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
exit(1);
}
+exit(0);
//
// Send Email to QA Team
@@ -615,11 +782,18 @@ function mail_qa_team($data, $compression, $status = FALSE)
// Write the given text to a temporary file, and return the filename.
//
-function save_text($filename,$text)
+function save_text($filename, $text, $filename_copy = null)
{
global $DETAILED;
- @file_put_contents($filename, $text) or error("Cannot open file '" . $filename . "' (save_text)");
+ if ($filename_copy && $filename_copy != $filename) {
+ if (@file_put_contents($filename_copy, $text) === false) {
+ 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
@@ -631,7 +805,7 @@ $text
// Write an error in a format recognizable to Emacs or MSVC.
//
-function error_report($testname,$logname,$tested)
+function error_report($testname, $logname, $tested)
{
$testname = realpath($testname);
$logname = realpath($logname);
@@ -647,15 +821,17 @@ function error_report($testname,$logname,$tested)
}
}
-function system_with_timeout($commandline)
+function system_with_timeout($commandline, $env = null)
{
+ global $leak_check;
+
$data = "";
$proc = proc_open($commandline, array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
- ), $pipes, null, null, array("suppress_errors" => true));
+ ), $pipes, null, $env, array("suppress_errors" => true));
if (!$proc)
return false;
@@ -667,7 +843,7 @@ function system_with_timeout($commandline)
$r = $pipes;
$w = null;
$e = null;
- $n = @stream_select($r, $w, $e, 60);
+ $n = @stream_select($r, $w, $e, $leak_check ? 300 : 60);
if ($n === 0) {
/* timed out */
@@ -691,18 +867,22 @@ function system_with_timeout($commandline)
return $data;
}
-function run_all_tests($test_files, $redir_tested = NULL)
+function run_all_tests($test_files, $env, $redir_tested = NULL)
{
global $test_results, $failed_tests_file, $php, $test_cnt, $test_idx;
- foreach($test_files AS $name) {
+ foreach($test_files AS $name)
+ {
$index = is_array($name) ? $name[0] : $name;
$test_idx++;
- $result = run_test($php,$name);
- if (!is_array($name) && $result != 'REDIR') {
+ $result = run_test($php, $name, $env);
+ if (!is_array($name) && $result != 'REDIR')
+ {
$test_results[$index] = $result;
- if ($failed_tests_file && ($result == 'FAILED' || $result == 'WARNED')) {
- if ($redir_tested) {
+ if ($failed_tests_file && ($result == 'FAILED' || $result == 'WARNED' || $result == 'LEAKED'))
+ {
+ if ($redir_tested)
+ {
fwrite($failed_tests_file, "# $redir_tested: $name\n");
} else {
fwrite($failed_tests_file, "$name\n");
@@ -715,11 +895,14 @@ function run_all_tests($test_files, $redir_tested = NULL)
//
// Run an individual test case.
//
-
-function run_test($php, $file)
+function run_test($php, $file, $env)
{
- global $log_format, $info_params, $ini_overwrites, $cwd, $PHP_FAILED_TESTS, $pass_options, $DETAILED, $IN_REDIRECT, $test_cnt, $test_idx;
+ 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;
+ $temp_filenames = null;
$org_file = $file;
if (is_array($file)) $file = $file[0];
@@ -734,6 +917,7 @@ TEST $file
'TEST' => '',
'SKIPIF' => '',
'GET' => '',
+ 'POST' => '',
'ARGS' => '',
);
@@ -752,18 +936,29 @@ TEST $file
$borked = true;
}
$section = 'TEST';
+ $secfile = false;
+ $secdone = false;
while (!feof($fp)) {
$line = fgets($fp);
// Match the beginning of a section.
- if (ereg('^--([A-Z]+)--',$line,$r)) {
+ if (preg_match('/^--([A-Z]+)--/', $line, $r)) {
$section = $r[1];
$section_text[$section] = '';
+ $secfile = $section == 'FILE' || $section == 'FILEEOF';
+ $secdone = false;
continue;
}
// Add to the section text.
- $section_text[$section] .= $line;
+ if (!$secdone) {
+ $section_text[$section] .= $line;
+ }
+
+ // End of actual test?
+ if ($secfile && preg_match('/^===DONE===/', $line, $r)) {
+ $secdone = true;
+ }
}
// the redirect section allows a set of tests to be reused outside of
@@ -776,82 +971,133 @@ TEST $file
$borked = false;
}
} else {
- if (@count($section_text['FILE']) != 1) {
- $bork_info = "missing section --FILE-- [$file]";
+ if (@count($section_text['FILE']) + @count($section_text['FILEEOF']) != 1) {
+ $bork_info = "missing section --FILE--";
$borked = true;
}
+ if (@count($section_text['FILEEOF']) == 1) {
+ $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) {
- $bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX-- [$file]";
+ $bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--";
$borked = true;
- print_r($section_text);
}
}
fclose($fp);
+ $shortname = str_replace($cwd.'/', '', $file);
+ $tested_file = $shortname;
+
if ($borked) {
- echo "BORK $bork_info [$file]\n";
+ show_result("BORK", $bork_info, $tested_file);
$PHP_FAILED_TESTS['BORKED'][] = array (
'name' => $file,
'test_name' => '',
'output' => '',
'diff' => '',
- 'info' => $bork_info,
+ 'info' => "$bork_info [$file]",
);
return 'BORKED';
}
- /* For GET/POST tests, check if cgi sapi is available and if it is, use it. */
- if ((!empty($section_text['GET']) || !empty($section_text['POST']))) {
- if (file_exists("./sapi/cgi/php")) {
- $old_php = $php;
- $php = realpath("./sapi/cgi/php") . ' -C ';
- }
- }
+ $tested = trim($section_text['TEST']);
- $shortname = str_replace($cwd.'/', '', $file);
- $tested = trim($section_text['TEST'])." [$shortname]";
+ /* For GET/POST tests, check if cgi sapi is available and if it is, use it. */
+ if ((!empty($section_text['GET']) || !empty($section_text['POST']))) {
+ if (file_exists("./sapi/cgi/php")) {
+ $old_php = $php;
+ $php = realpath("./sapi/cgi/php") . ' -C ';
+ } else {
+ show_result("SKIP", $tested, $tested_file, "reason: CGI not available");
+ return 'SKIPPED';
+ }
+ }
- echo "TEST $test_idx/$test_cnt [$shortname]\r";
- flush();
+ show_test($test_idx, $shortname);
if (is_array($IN_REDIRECT)) {
- $tmp = $IN_REDIRECT['dir'];
+ $temp_dir = $test_dir = $IN_REDIRECT['dir'];
} else {
- $tmp = realpath(dirname($file));
+ $temp_dir = $test_dir = realpath(dirname($file));
+ }
+ if ($temp_source && $temp_target) {
+ $temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
}
- $diff_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\.phpt$','.diff', basename($file));
- $log_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\.phpt$','.log', basename($file));
- $exp_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\.phpt$','.exp', basename($file));
- $output_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\.phpt$','.out', basename($file));
-
- $tmp_skipif = $tmp . DIRECTORY_SEPARATOR . uniqid('/phpt.');
- $tmp_file = $tmp . DIRECTORY_SEPARATOR . preg_replace('/\.phpt$/','.php',basename($file));
- $tmp_post = $tmp . DIRECTORY_SEPARATOR . uniqid('/phpt.');
+ $diff_filename = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'diff';
+ $log_filename = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'log';
+ $exp_filename = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'exp';
+ $output_filename = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'out';
+ $memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'mem';
+ $temp_file = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'php';
+ $test_file = $test_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'php';
+ $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'skip.php';
+ $test_skipif = $test_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'skip.php';
+ $temp_clean = $temp_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'clean.php';
+ $test_clean = $test_dir . DIRECTORY_SEPARATOR . basename($file,'phpt').'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 .= '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));
+ }
+ if (isset($section_text['FILE'])) {
+ save_text($copy_file, $section_text['FILE']);
+ }
+ $temp_filenames = array(
+ 'file' => $copy_file,
+ 'diff' => $diff_filename,
+ 'log' => $log_filename,
+ 'exp' => $exp_filename,
+ 'out' => $output_filename,
+ 'mem' => $memcheck_filename,
+ 'php' => $temp_file,
+ 'skip' => $temp_skipif,
+ 'clean'=> $temp_clean);
+ }
if (is_array($IN_REDIRECT)) {
- $tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']) . " [$tmp_file]";
+ $tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']);
+ $tested_file = $tmp_relative_file;
$section_text['FILE'] = "# original source file: $shortname\n" . $section_text['FILE'];
}
- @unlink($tmp_skipif);
- @unlink($tmp_file);
- @unlink($tmp_post);
-
// unlink old test results
@unlink($diff_filename);
@unlink($log_filename);
@unlink($exp_filename);
@unlink($output_filename);
+ @unlink($memcheck_filename);
+ @unlink($temp_file);
+ @unlink($test_file);
+ @unlink($temp_skipif);
+ @unlink($test_skipif);
+ @unlink($tmp_post);
+ @unlink($temp_clean);
+ @unlink($test_clean);
// Reset environment from any previous test.
- putenv("REDIRECT_STATUS=");
- putenv("QUERY_STRING=");
- putenv("PATH_TRANSLATED=");
- putenv("SCRIPT_FILENAME=");
- putenv("REQUEST_METHOD=");
- putenv("CONTENT_TYPE=");
- putenv("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", $section_text['ENV']) as $e) {
+ $e = explode('=',trim($e));
+ if (count($e) == 2) {
+ $env[$e[0]] = $e[1];
+ }
+ }
+ }
// Check if test should be skipped.
$info = '';
@@ -862,31 +1108,40 @@ TEST $file
settings2array($ini_overwrites,$skipif_params);
settings2params($skipif_params);
- save_text($tmp_skipif, $section_text['SKIPIF']);
+ if ($cfg['show']['skip']) {
+ echo "\n========SKIP========\n";
+ echo $section_text['SKIPIF'];
+ echo "========DONE========\n";
+ }
+ save_text($test_skipif, $section_text['SKIPIF'], $temp_skipif);
$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 $tmp_skipif");
- @unlink($tmp_skipif);
- if (eregi("^skip", trim($output))) {
- echo "SKIP $tested";
+ $output = system_with_timeout("$extra $php -q $skipif_params $test_skipif", $env);
+ 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) {
- echo " (reason: $reason)\n";
+ show_result("SKIP", $tested, $tested_file, "reason: $reason", $temp_filenames);
} else {
- echo "\n";
+ show_result("SKIP", $tested, $tested_file, '', $temp_filenames);
}
if (isset($old_php)) {
$php = $old_php;
}
+ if (!$cfg['keep']['skip']) {
+ @unlink($test_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 */
@@ -904,43 +1159,47 @@ TEST $file
$IN_REDIRECT['dir'] = realpath(dirname($file));
$IN_REDIRECT['prefix'] = trim($section_text['TEST']);
- if (is_array($org_file)) {
- $test_files[] = $org_file[1];
- } else {
- $GLOBALS['test_files'] = $test_files;
- find_files($IN_REDIRECT['TESTS']);
- $test_files = $GLOBALS['test_files'];
- }
- $test_cnt += count($test_files) - 1;
- $test_idx--;
-
- echo "---> $IN_REDIRECT[TESTS] ($tested)\n";
-
- // set up environment
- foreach ($IN_REDIRECT['ENV'] as $k => $v) {
- putenv("$k=$v");
- }
- putenv("REDIR_TEST_DIR=" . realpath($IN_REDIRECT['TESTS']) . DIRECTORY_SEPARATOR);
-
- usort($test_files, "test_sort");
- run_all_tests($test_files, $tested);
+ if (@count($IN_REDIRECT['TESTS']) == 1) {
+ if (is_array($org_file)) {
+ $test_files[] = $org_file[1];
+ } else {
+ $GLOBALS['test_files'] = $test_files;
+ find_files($IN_REDIRECT['TESTS']);
+ $test_files = $GLOBALS['test_files'];
+ }
+ $test_cnt += count($test_files) - 1;
+ $test_idx--;
- echo "---> $IN_REDIRECT[TESTS] ($tested) done\n";
+ show_redirect_start($IN_REDIRECT['TESTS'], $tested, $tested_file);
- // clean up environment
- foreach ($IN_REDIRECT['ENV'] as $k => $v) {
- putenv("$k=");
+ // set up environment
+ $redirenv = array_merge($environment, $IN_REDIRECT['ENV']);
+ $redirenv['REDIR_TEST_DIR'] = realpath($IN_REDIRECT['TESTS']) . DIRECTORY_SEPARATOR;
+
+ usort($test_files, "test_sort");
+ run_all_tests($test_files, $redirenv, $tested);
+
+ show_redirect_ends($IN_REDIRECT['TESTS'], $tested, $tested_file);
+
+ // a redirected test never fails
+ $IN_REDIRECT = false;
+ return 'REDIR';
}
- putenv("REDIR_TEST_DIR=");
-
- // a redirected test never fails
- $IN_REDIRECT = false;
- return 'REDIR';
- } else if (is_array($org_file)) {
- echo "--> Redirected test did not contain redirection info: $org_file[0]\n";
- $test_cnt -= 1;
- $test_idx--;
- return 'REDIR';
+ }
+ if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) {
+ 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 (
+ 'name' => $file,
+ 'test_name' => '',
+ 'output' => '',
+ 'diff' => '',
+ 'info' => "$bork_info [$file]",
+ );
+ //$test_cnt -= 1; // Only if is_array($org_file) ?
+ //$test_idx--;
+ return 'BORKED';
}
@@ -950,85 +1209,110 @@ TEST $file
//$ini_overwrites[] = 'setting=value';
settings2array($ini_overwrites, $ini_settings);
- // Any special ini settings
+ // 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);
// We've satisfied the preconditions - run the test!
- save_text($tmp_file,$section_text['FILE']);
+ if ($cfg['show']['php']) {
+ echo "\n========TEST========\n";
+ echo $section_text['FILE'];
+ echo "========DONE========\n";
+ }
+ save_text($test_file, $section_text['FILE'], $temp_file);
if (array_key_exists('GET', $section_text)) {
$query_string = trim($section_text['GET']);
} else {
$query_string = '';
}
- if (!empty($section_text['ENV'])) {
- foreach (explode("\n", $section_text['ENV']) as $env) {
- ($env = trim($env)) and putenv($env);
- }
- }
-
- putenv("REDIRECT_STATUS=1");
- putenv("QUERY_STRING=$query_string");
- putenv("PATH_TRANSLATED=$tmp_file");
- putenv("SCRIPT_FILENAME=$tmp_file");
+ $env['REDIRECT_STATUS'] = '1';
+ $env['QUERY_STRING'] = $query_string;
+ $env['PATH_TRANSLATED'] = $test_file;
+ $env['SCRIPT_FILENAME'] = $test_file;
$args = $section_text['ARGS'] ? ' -- '.$section_text['ARGS'] : '';
if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
$post = trim($section_text['POST']);
- save_text($tmp_post,$post);
+ save_text($tmp_post, $post);
$content_length = strlen($post);
- putenv("REQUEST_METHOD=POST");
- putenv("CONTENT_TYPE=application/x-www-form-urlencoded");
- putenv("CONTENT_LENGTH=$content_length");
+ $env['REQUEST_METHOD'] = 'POST';
+ $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
+ $env['CONTENT_LENGTH'] = $content_length;
- $cmd = "$php$pass_options$ini_settings -f \"$tmp_file\" 2>&1 < $tmp_post";
+ $cmd = "$php$pass_options$ini_settings -f \"$test_file\" 2>&1 < $tmp_post";
} else {
- putenv("REQUEST_METHOD=GET");
- putenv("CONTENT_TYPE=");
- putenv("CONTENT_LENGTH=");
+ $env['REQUEST_METHOD'] = 'GET';
+ $env['CONTENT_TYPE'] = '';
+ $env['CONTENT_LENGTH'] = '';
- if (empty($section_text['ENV'])) {
- $cmd = "$php$pass_options$ini_settings -f \"$tmp_file\" $args 2>&1";
- } else {
- $cmd = "$php$pass_options$ini_settings < \"$tmp_file\" $args 2>&1";
- }
+ $cmd = "$php$pass_options$ini_settings -f \"$test_file\" $args 2>&1";
+ }
+
+ if ($leak_check) {
+ $cmd = "valgrind -q --tool=memcheck --log-file-exactly=$memcheck_filename $cmd";
}
if ($DETAILED) echo "
-CONTENT_LENGTH = " . getenv("CONTENT_LENGTH") . "
-CONTENT_TYPE = " . getenv("CONTENT_TYPE") . "
-PATH_TRANSLATED = " . getenv("PATH_TRANSLATED") . "
-QUERY_STRING = " . getenv("QUERY_STRING") . "
-REDIRECT_STATUS = " . getenv("REDIRECT_STATUS") . "
-REQUEST_METHOD = " . getenv("REQUEST_METHOD") . "
-SCRIPT_FILENAME = " . getenv("SCRIPT_FILENAME") . "
+CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . "
+CONTENT_TYPE = " . $env['CONTENT_TYPE'] . "
+PATH_TRANSLATED = " . $env['PATH_TRANSLATED'] . "
+QUERY_STRING = " . $env['QUERY_STRING'] . "
+REDIRECT_STATUS = " . $env['REDIRECT_STATUS'] . "
+REQUEST_METHOD = " . $env['REQUEST_METHOD'] . "
+SCRIPT_FILENAME = " . $env['SCRIPT_FILENAME'] . "
COMMAND $cmd
";
-// $out = `$cmd`;
- $out = system_with_timeout($cmd);
+ $out = system_with_timeout($cmd, $env);
- if (!empty($section_text['ENV'])) {
- foreach (explode("\n", $section_text['ENV']) as $env) {
- $env = explode('=', $env);
- putenv($env[0] .'=');
+ 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 $test_clean", $env);
+ }
+ if (!$cfg['keep']['clean']) {
+ @unlink($test_clean);
+ }
}
}
@unlink($tmp_post);
+ $leaked = false;
+ $passed = false;
+
+ if ($leak_check) { // leak check
+ $leaked = @filesize($memcheck_filename) > 0;
+ if (!$leaked) {
+ @unlink($memcheck_filename);
+ }
+ }
+
// 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) {
@@ -1047,6 +1331,7 @@ COMMAND $cmd
// Stick to basics
$wanted_re = str_replace("%e", '\\' . DIRECTORY_SEPARATOR, $wanted_re);
$wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy
+ $wanted_re = str_replace("%w", "\s*", $wanted_re);
$wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re);
$wanted_re = str_replace("%d", "[0-9]+", $wanted_re);
$wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re);
@@ -1060,85 +1345,92 @@ COMMAND $cmd
var_dump($output);
*/
if (preg_match("/^$wanted_re\$/s", $output)) {
- @unlink($tmp_file);
- echo "PASS $tested\n";
+ $passed = true;
+ if (!$cfg['keep']['php']) {
+ @unlink($test_file);
+ }
if (isset($old_php)) {
$php = $old_php;
}
- return 'PASSED';
+ if (!$leaked) {
+ show_result("PASS", $tested, $tested_file, '', $temp_filenames);
+ return 'PASSED';
+ }
}
-
} else {
$wanted = trim($section_text['EXPECT']);
$wanted = preg_replace('/\r\n/',"\n",$wanted);
// compare and leave on success
- $ok = (0 == strcmp($output,$wanted));
- if ($ok) {
- @unlink($tmp_file);
- echo "PASS $tested\n";
+ if (!strcmp($output, $wanted)) {
+ $passed = true;
+ if (!$cfg['keep']['php']) {
+ @unlink($test_file);
+ }
if (isset($old_php)) {
$php = $old_php;
}
- return 'PASSED';
+ if (!$leaked) {
+ show_result("PASS", $tested, $tested_file, '', $temp_filenames);
+ return 'PASSED';
+ }
}
$wanted_re = NULL;
}
// Test failed so we need to report details.
- if ($warn) {
- echo "WARN $tested$info\n";
+
+ if ($leaked) {
+ $restype = 'LEAK';
+ } else if ($warn) {
+ $restype = 'WARN';
} else {
- echo "FAIL $tested$info\n";
- }
-
- $PHP_FAILED_TESTS['FAILED'][] = array (
- 'name' => $file,
- 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested,
- 'output' => $output_filename,
- 'diff' => $diff_filename,
- 'info' => $info
- );
-
- // 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);
+ $restype = 'FAIL';
}
- // 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);
- }
-
- // 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);
- }
-
- // write .log
- if (strpos($log_format,'L') !== FALSE) {
- $log = fopen($log_filename,'wt') or error("Cannot create test log - $log_filename");
- fwrite($log,"
+ if (!$passed) {
+ // write .exp
+ if (strpos($log_format,'E') !== FALSE && file_put_contents($exp_filename, $wanted) === FALSE) {
+ error("Cannot create expected test output - $exp_filename");
+ }
+
+ // write .out
+ if (strpos($log_format,'O') !== FALSE && file_put_contents($output_filename, $output) === FALSE) {
+ error("Cannot create test output - $output_filename");
+ }
+
+ // write .diff
+ if (strpos($log_format,'D') !== FALSE && file_put_contents($diff_filename, generate_diff($wanted,$wanted_re,$output)) === FALSE) {
+ error("Cannot create test diff - $diff_filename");
+ }
+
+ // write .log
+ if (strpos($log_format,'L') !== FALSE && file_put_contents($log_filename, "
---- EXPECTED OUTPUT
$wanted
---- ACTUAL OUTPUT
$output
---- FAILED
-");
- fclose($log);
- error_report($file,$log_filename,$tested);
+") === FALSE) {
+ error("Cannot create test log - $log_filename");
+ error_report($file, $log_filename, $tested);
+ }
}
+ show_result($restype, $tested, $tested_file, $info, $temp_filenames);
+
+ $PHP_FAILED_TESTS[$restype.'ED'][] = array (
+ 'name' => $file,
+ 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [$tested_file]",
+ 'output' => $output_filename,
+ 'diff' => $diff_filename,
+ 'info' => $info
+ );
+
if (isset($old_php)) {
$php = $old_php;
}
- return $warn ? 'WARNED' : 'FAILED';
+ return $restype.'ED';
}
function comp_line($l1,$l2,$is_reg)
@@ -1287,7 +1579,7 @@ function compute_summary()
$n_total = count($test_results);
$n_total += $ignored_by_ext;
- $sum_results = array('PASSED'=>0, 'WARNED'=>0, 'SKIPPED'=>0, 'FAILED'=>0, 'BORKED'=>0);
+ $sum_results = array('PASSED'=>0, 'WARNED'=>0, 'SKIPPED'=>0, 'FAILED'=>0, 'BORKED'=>0, 'LEAKED'=>0);
foreach ($test_results as $v) {
$sum_results[$v]++;
}
@@ -1298,20 +1590,22 @@ function compute_summary()
}
}
-function get_summary($show_ext_summary)
+function get_summary($show_ext_summary, $show_html)
{
- global $exts_skipped, $exts_tested, $n_total, $sum_results, $percent_results, $end_time, $start_time, $failed_test_summary, $PHP_FAILED_TESTS;
+ 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;
+ $x_leaked = (100.0 * $sum_results['LEAKED']) / $x_total;
$x_passed = (100.0 * $sum_results['PASSED']) / $x_total;
} else {
- $x_warned = $x_failed = $x_passed = 0;
+ $x_warned = $x_failed = $x_passed = $x_leaked = 0;
}
$summary = "";
+ if ($show_html) $summary .= "<pre>\n";
if ($show_ext_summary) {
$summary .= "
=====================================================================
@@ -1330,9 +1624,14 @@ Tests borked : " . sprintf("%4d (%5.1f%%)",$sum_results['BORKED'],$percent_re
}
$summary .= "
Tests skipped : " . sprintf("%4d (%5.1f%%)",$sum_results['SKIPPED'],$percent_results['SKIPPED']) . " --------
-Tests warned : " . sprintf("%4d (%5.1f%%)",$sum_results['WARNED'],$percent_results['WARNED']) . " " . sprintf("(%5.1f%%)",$x_warned) . "
-Tests failed : " . sprintf("%4d (%5.1f%%)",$sum_results['FAILED'],$percent_results['FAILED']) . " " . sprintf("(%5.1f%%)",$x_failed) . "
-Tests passed : " . sprintf("%4d (%5.1f%%)",$sum_results['PASSED'],$percent_results['PASSED']) . " " . sprintf("(%5.1f%%)",$x_passed) . "
+Tests warned : " . sprintf("%4d (%5.1f%%)",$sum_results['WARNED'], $percent_results['WARNED']) . " " . sprintf("(%5.1f%%)",$x_warned) . "
+Tests failed : " . sprintf("%4d (%5.1f%%)",$sum_results['FAILED'], $percent_results['FAILED']) . " " . sprintf("(%5.1f%%)",$x_failed);
+ if ($leak_check) {
+ $summary .= "
+Tests leaked : " . sprintf("%4d (%5.1f%%)",$sum_results['LEAKED'], $percent_results['LEAKED']) . " " . sprintf("(%5.1f%%)",$x_leaked);
+ }
+ $summary .= "
+Tests passed : " . sprintf("%4d (%5.1f%%)",$sum_results['PASSED'], $percent_results['PASSED']) . " " . sprintf("(%5.1f%%)",$x_passed) . "
---------------------------------------------------------------------
Time taken : " . sprintf("%4d seconds", $end_time - $start_time) . "
=====================================================================
@@ -1362,13 +1661,136 @@ FAILED TEST SUMMARY
$failed_test_summary .= "=====================================================================\n";
}
+ if (count($PHP_FAILED_TESTS['LEAKED'])) {
+ $failed_test_summary .= "
+=====================================================================
+LEAKED TEST SUMMARY
+---------------------------------------------------------------------
+";
+ 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";
+ }
+
if ($failed_test_summary && !getenv('NO_PHPTEST_SUMMARY')) {
$summary .= $failed_test_summary;
}
+ if ($show_html) $summary .= "</pre>";
+
return $summary;
}
+function show_start($start_time)
+{
+ global $html_output, $html_file;
+
+ 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";
+}
+
+function show_end($end_time)
+{
+ global $html_output, $html_file;
+
+ 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";
+}
+
+function show_summary()
+{
+ global $html_output, $html_file;
+
+ if ($html_output)
+ {
+ fwrite($html_file, "<hr/>\n" . get_summary(true, true));
+ }
+ echo get_summary(true, false);
+}
+
+function show_redirect_start($tests, $tested, $tested_file)
+{
+ global $html_output, $html_file;
+
+ 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";
+}
+
+function show_redirect_ends($tests, $tested, $tested_file)
+{
+ global $html_output, $html_file;
+
+ 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";
+}
+
+function show_test($test_idx, $shortname)
+{
+ global $test_cnt;
+
+ echo "TEST $test_idx/$test_cnt [$shortname]\r";
+ flush();
+}
+
+function show_result($result, $tested, $tested_file, $extra = '', $temp_filenames = null)
+{
+ global $html_output, $html_file, $temp_target, $temp_urlbase;
+
+ echo "$result $tested [$tested_file] $extra\n";
+
+ 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>" .
+ "<td>$tested</td>" .
+ "<td>$extra</td>" .
+ "<td>$diff</td>" .
+ "<td>$mem</td>" .
+ "</tr>\n");
+ }
+}
+
/*
* Local variables:
* tab-width: 4