summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-11 15:43:42 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-11 15:43:42 +0100
commit8f1428d29ef91d74b4d272af171675f2971eb15b (patch)
treea1f4f4d7dc5bfe8096806dd5c5266634e19fa07a /run-tests.php
parentc6e4182351e0173fe58de141e143aac2eacf5efe (diff)
downloadphp-upstream/5.3.9.tar.gz
Imported Upstream version 5.3.9upstream/5.3.9
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php395
1 files changed, 267 insertions, 128 deletions
diff --git a/run-tests.php b/run-tests.php
index 8638cc5e6..1471ca984 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -2,7 +2,7 @@
<?php
/*
+----------------------------------------------------------------------+
- | PHP Version 5, 6 |
+ | PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
@@ -24,7 +24,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: run-tests.php 314690 2011-08-09 21:53:44Z nlopess $ */
+/* $Id: run-tests.php 320475 2011-12-06 05:44:54Z derick $ */
/* 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
@@ -80,13 +80,6 @@ if (PHP_VERSION_ID < 50300) {
}
}
-// (unicode) is available from 6.0.0
-if (PHP_VERSION_ID < 60000) {
- define('STRING_TYPE', 'string');
-} else {
- define('STRING_TYPE', 'unicode');
-}
-
// If timezone is not set, use UTC.
if (ini_get('date.timezone') == '') {
date_default_timezone_set('UTC');
@@ -207,6 +200,32 @@ if (getenv('TEST_PHP_DETAILED')) {
$DETAILED = 0;
}
+// Check whether a junit log is wanted.
+$JUNIT = getenv('TEST_PHP_JUNIT');
+if (empty($JUNIT) || (!file_exists($JUNIT) && !is_writable(dirname($JUNIT))) || (file_exists($JUNIT) && !is_writable($JUNIT)) || !($JUNIT = @fopen($JUNIT, 'w'))) {
+ $JUNIT = FALSE;
+}
+else{
+ $JUNIT = array(
+ 'fp' => $JUNIT,
+ 'test_total' => 0,
+ 'test_pass' => 0,
+ 'test_fail' => 0,
+ 'test_error' => 0,
+ 'test_skip' => 0,
+ 'started_at' => microtime(true),
+ 'finished_at' => NULL,
+ 'execution_time'=> NULL,
+ 'result_xml' => '',
+ );
+}
+
+if (getenv('SHOW_ONLY_GROUPS')) {
+ $SHOW_ONLY_GROUPS = explode(",", getenv('SHOW_ONLY_GROUPS'));
+} else {
+ $SHOW_ONLY_GROUPS = array();
+}
+
// Check whether user test dirs are requested.
if (getenv('TEST_PHP_USER')) {
$user_tests = explode (',', getenv('TEST_PHP_USER'));
@@ -560,6 +579,9 @@ if (isset($argc) && $argc > 1) {
case 'd':
$ini_overwrites[] = $argv[++$i];
break;
+ case 'g':
+ $SHOW_ONLY_GROUPS = explode(",", $argv[++$i]);;
+ break;
//case 'h'
case '--keep-all':
foreach($cfgfiles as $file) {
@@ -644,7 +666,7 @@ if (isset($argc) && $argc > 1) {
$html_output = is_resource($html_file);
break;
case '--version':
- echo '$Revision: 314690 $' . "\n";
+ echo '$Revision: 320475 $' . "\n";
exit(1);
default:
@@ -675,6 +697,9 @@ Options:
-d foo=bar Pass -d option to the php binary (Define INI entry foo
with value 'bar').
+ -g Comma seperated list of groups to show during test run
+ (possible values: PASS, FAIL, XFAIL, SKIP, BORK, WARN, LEAK, REDIRECT).
+
-m Test for memory leaks with Valgrind.
-p <php> Specify PHP executable to run.
@@ -806,6 +831,10 @@ HELP;
if ($output_file != '' && $just_save_results) {
save_or_mail_results();
}
+
+ if ($JUNIT) {
+ save_junit_xml();
+ }
if (getenv('REPORT_EXIT_STATUS') == 1 and preg_match('/FAILED(?: |$)/', implode(' ', $test_results))) {
exit(1);
@@ -854,7 +883,7 @@ function find_files($dir, $is_ext_dir = false, $ignore = false)
while (($name = readdir($o)) !== false) {
- if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS'))) {
+ if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', '.svn'))) {
$skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test));
if ($skip_ext) {
$exts_skipped++;
@@ -941,6 +970,10 @@ if ($html_output) {
save_or_mail_results();
+if ($JUNIT) {
+ save_junit_xml();
+}
+
if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
exit(1);
}
@@ -1002,12 +1035,12 @@ function save_text($filename, $text, $filename_copy = null)
global $DETAILED;
if ($filename_copy && $filename_copy != $filename) {
- if (file_put_contents($filename_copy, (binary) $text, FILE_BINARY) === false) {
+ if (file_put_contents($filename_copy, $text, FILE_BINARY) === false) {
error("Cannot open file '" . $filename_copy . "' (save_text)");
}
}
- if (file_put_contents($filename, (binary) $text, FILE_BINARY) === false) {
+ if (file_put_contents($filename, $text, FILE_BINARY) === false) {
error("Cannot open file '" . $filename . "' (save_text)");
}
@@ -1043,11 +1076,11 @@ function system_with_timeout($commandline, $env = null, $stdin = null)
{
global $leak_check, $cwd;
- $data = b'';
+ $data = '';
$bin_env = array();
foreach((array)$env as $key => $value) {
- $bin_env[(binary)$key] = (binary)$value;
+ $bin_env[$key] = $value;
}
$proc = proc_open($commandline, array(
@@ -1061,7 +1094,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null)
}
if (!is_null($stdin)) {
- fwrite($pipes[0], (binary) $stdin);
+ fwrite($pipes[0], $stdin);
}
fclose($pipes[0]);
@@ -1079,11 +1112,11 @@ function system_with_timeout($commandline, $env = null, $stdin = null)
break;
} else if ($n === 0) {
/* timed out */
- $data .= b"\n ** ERROR: process timed out **\n";
+ $data .= "\n ** ERROR: process timed out **\n";
proc_terminate($proc, 9);
return $data;
} else if ($n > 0) {
- $line = (binary) fread($pipes[1], 8192);
+ $line = fread($pipes[1], 8192);
if (strlen($line) == 0) {
/* EOF */
break;
@@ -1095,7 +1128,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null)
$stat = proc_get_status($proc);
if ($stat['signaled']) {
- $data .= b"\nTermsig=" . $stat['stopsig'];
+ $data .= "\nTermsig=" . $stat['stopsig'];
}
$code = proc_close($proc);
@@ -1150,21 +1183,6 @@ function show_file_block($file, $block, $section = null)
}
}
-function binary_section($section)
-{
- return PHP_MAJOR_VERSION < 6 ||
- (
- $section == 'FILE' ||
- $section == 'FILEEOF' ||
- $section == 'EXPECT' ||
- $section == 'EXPECTF' ||
- $section == 'EXPECTREGEX' ||
- $section == 'EXPECTHEADERS' ||
- $section == 'SKIPIF' ||
- $section == 'CLEAN'
- );
-}
-
//
// Run an individual test case.
//
@@ -1175,6 +1193,7 @@ function run_test($php, $file, $env)
global $leak_check, $temp_source, $temp_target, $cfg, $environment;
global $no_clean;
global $valgrind_version;
+ global $JUNIT;
$temp_filenames = null;
$org_file = $file;
@@ -1227,37 +1246,28 @@ TEST $file
}
// Match the beginning of a section.
- if (preg_match(b'/^--([_A-Z]+)--/', $line, $r)) {
+ if (preg_match('/^--([_A-Z]+)--/', $line, $r)) {
$section = $r[1];
- settype($section, STRING_TYPE);
+ settype($section, 'string');
if (isset($section_text[$section])) {
$bork_info = "duplicated $section section";
$borked = true;
}
- $section_text[$section] = binary_section($section) ? b'' : '';
+ $section_text[$section] = '';
$secfile = $section == 'FILE' || $section == 'FILEEOF' || $section == 'FILE_EXTERNAL';
$secdone = false;
continue;
}
- if (!binary_section($section)) {
- $line = unicode_decode($line, "utf-8");
- if ($line == false) {
- $bork_info = "cannot read test";
- $borked = true;
- break;
- }
- }
-
// Add to the section text.
if (!$secdone) {
$section_text[$section] .= $line;
}
// End of actual test?
- if ($secfile && preg_match(b'/^===DONE===\s*$/', $line)) {
+ if ($secfile && preg_match('/^===DONE===\s*$/', $line)) {
$secdone = true;
}
}
@@ -1282,7 +1292,7 @@ TEST $file
}
if (@count($section_text['FILEEOF']) == 1) {
- $section_text['FILE'] = preg_replace(b"/[\r\n]+$/", b'', $section_text['FILEEOF']);
+ $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
unset($section_text['FILEEOF']);
}
@@ -1319,6 +1329,14 @@ TEST $file
'diff' => '',
'info' => "$bork_info [$file]",
);
+
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_error']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested_file, ENT_QUOTES).'" time="0">'."\n";
+ $JUNIT['result_xml'] .= '<error type="BORKED" message="'.$bork_info.'" />'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'BORKED';
}
@@ -1341,6 +1359,13 @@ TEST $file
$php = realpath("./sapi/cgi/php-cgi") . ' -C ';
} else {
show_result('SKIP', $tested, $tested_file, "reason: CGI not available");
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_skip']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="0">'."\n";
+ $JUNIT['result_xml'] .= '<skipped>CGI not available</skipped>'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'SKIPPED';
}
}
@@ -1458,6 +1483,18 @@ TEST $file
settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings);
}
+ // Additional required extensions
+ if (array_key_exists('EXTENSIONS', $section_text)) {
+ $ext_dir=`$php -r 'echo ini_get("extension_dir");'`;
+ $extensions = preg_split("/[\n\r]+/", trim($section_text['EXTENSIONS']));
+ $loaded = explode(",", `$php -n -r 'echo join(",", get_loaded_extensions());'`);
+ foreach ($extensions as $req_ext) {
+ if (!in_array($req_ext, $loaded)) {
+ $ini_settings['extension'][] = $ext_dir . DIRECTORY_SEPARATOR . $req_ext . '.' . PHP_SHLIB_SUFFIX;
+ }
+ }
+ }
+
settings2params($ini_settings);
// Check if test should be skipped.
@@ -1478,7 +1515,14 @@ TEST $file
$env['USE_ZEND_ALLOC'] = '1';
}
+ if ($JUNIT) {
+ $test_started_at = microtime(true);
+ }
$output = system_with_timeout("$extra $php $pass_options -q $ini_settings -d display_errors=0 $test_skipif", $env);
+ if ($JUNIT) {
+ $test_finished_at = microtime(true);
+ $test_execution_time= number_format($test_finished_at-$test_started_at, 2);
+ }
if (!$cfg['keep']['skip']) {
@unlink($test_skipif);
@@ -1500,6 +1544,13 @@ TEST $file
@unlink($test_skipif);
}
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_skip']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '<skipped><![CDATA['."\n".$m[1]."\n".']]></skipped>'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'SKIPPED';
}
@@ -1554,6 +1605,12 @@ TEST $file
// a redirected test never fails
$IN_REDIRECT = false;
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_pass']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'REDIR';
} else {
@@ -1585,6 +1642,13 @@ TEST $file
'diff' => '',
'info' => "$bork_info [$file]",
);
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_error']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '<error type="BORKED" message="'.$bork_info.'" />'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'BORKED';
}
@@ -1638,6 +1702,13 @@ TEST $file
$env['REQUEST_METHOD'] = 'POST';
if (empty($request)) {
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_error']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '<error type="BORKED" message="empty $request" />'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'BORKED';
}
@@ -1700,7 +1771,14 @@ HTTP_COOKIE = " . $env['HTTP_COOKIE'] . "
COMMAND $cmd
";
- $out = (binary) system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
+ if ($JUNIT) {
+ $test_started_at = microtime(true);
+ }
+ $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
+ if ($JUNIT) {
+ $test_finished_at = microtime(true);
+ $test_execution_time= number_format($test_finished_at-$test_started_at, 2);
+ }
if (array_key_exists('CLEAN', $section_text) && (!$no_clean || $cfg['keep']['clean'])) {
@@ -1737,19 +1815,19 @@ COMMAND $cmd
}
// Does the output match what is expected?
- $output = preg_replace(b"/\r\n/", b"\n", trim($out));
+ $output = preg_replace("/\r\n/", "\n", trim($out));
/* when using CGI, strip the headers from the output */
- $headers = b"";
+ $headers = "";
- if (isset($old_php) && preg_match(b"/^(.*?)\r?\n\r?\n(.*)/s", $out, $match)) {
+ if (isset($old_php) && preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $out, $match)) {
$output = trim($match[2]);
- $rh = preg_split(b"/[\n\r]+/", $match[1]);
+ $rh = preg_split("/[\n\r]+/", $match[1]);
$headers = array();
foreach ($rh as $line) {
- if (strpos($line, b':') !== false) {
- $line = explode(b':', $line, 2);
+ if (strpos($line, ':') !== false) {
+ $line = explode(':', $line, 2);
$headers[trim($line[0])] = trim($line[1]);
}
}
@@ -1760,13 +1838,13 @@ COMMAND $cmd
if (isset($section_text['EXPECTHEADERS'])) {
$want = array();
$wanted_headers = array();
- $lines = preg_split(b"/[\n\r]+/", (binary) $section_text['EXPECTHEADERS']);
+ $lines = preg_split("/[\n\r]+/", $section_text['EXPECTHEADERS']);
foreach($lines as $line) {
- if (strpos($line, b':') !== false) {
- $line = explode(b':', $line, 2);
+ if (strpos($line, ':') !== false) {
+ $line = explode(':', $line, 2);
$want[trim($line[0])] = trim($line[1]);
- $wanted_headers[] = trim($line[0]) . b': ' . trim($line[1]);
+ $wanted_headers[] = trim($line[0]) . ': ' . trim($line[1]);
}
}
@@ -1778,7 +1856,7 @@ COMMAND $cmd
if (isset($org_headers[$k])) {
$headers = $org_headers[$k];
- $output_headers[] = $k . b': ' . $org_headers[$k];
+ $output_headers[] = $k . ': ' . $org_headers[$k];
}
if (!isset($org_headers[$k]) || $org_headers[$k] != $v) {
@@ -1787,9 +1865,9 @@ COMMAND $cmd
}
ksort($wanted_headers);
- $wanted_headers = join(b"\n", $wanted_headers);
+ $wanted_headers = join("\n", $wanted_headers);
ksort($output_headers);
- $output_headers = join(b"\n", $output_headers);
+ $output_headers = join("\n", $output_headers);
}
show_file_block('out', $output);
@@ -1803,13 +1881,13 @@ COMMAND $cmd
}
show_file_block('exp', $wanted);
- $wanted_re = preg_replace(b'/\r\n/', b"\n", $wanted);
+ $wanted_re = preg_replace('/\r\n/', "\n", $wanted);
if (isset($section_text['EXPECTF'])) {
// do preg_quote, but miss out any %r delimited sections
- $temp = b"";
- $r = b"%r";
+ $temp = "";
+ $r = "%r";
$startOffset = 0;
$length = strlen($wanted_re);
while($startOffset < $length) {
@@ -1826,47 +1904,47 @@ COMMAND $cmd
$start = $end = $length;
}
// quote a non re portion of the string
- $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), b'/');
+ $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), '/');
// add the re unquoted.
if ($end > $start) {
- $temp = $temp . b'(' . substr($wanted_re, $start+2, ($end - $start-2)). b')';
+ $temp = $temp . '(' . substr($wanted_re, $start+2, ($end - $start-2)). ')';
}
$startOffset = $end + 2;
}
$wanted_re = $temp;
$wanted_re = str_replace(
- array(b'%binary_string_optional%'),
- version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? b'string' : b'binary string',
+ array('%binary_string_optional%'),
+ 'string',
$wanted_re
);
$wanted_re = str_replace(
- array(b'%unicode_string_optional%'),
- version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? b'string' : b'Unicode string',
+ array('%unicode_string_optional%'),
+ 'string',
$wanted_re
);
$wanted_re = str_replace(
- array(b'%unicode\|string%', b'%string\|unicode%'),
- version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? b'string' : b'unicode',
+ array('%unicode\|string%', '%string\|unicode%'),
+ 'string',
$wanted_re
);
$wanted_re = str_replace(
- array(b'%u\|b%', b'%b\|u%'),
- version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? b'' : b'u',
+ array('%u\|b%', '%b\|u%'),
+ '',
$wanted_re
);
// Stick to basics
- $wanted_re = str_replace(b'%e', b'\\' . DIRECTORY_SEPARATOR, $wanted_re);
- $wanted_re = str_replace(b'%s', b'[^\r\n]+', $wanted_re);
- $wanted_re = str_replace(b'%S', b'[^\r\n]*', $wanted_re);
- $wanted_re = str_replace(b'%a', b'.+', $wanted_re);
- $wanted_re = str_replace(b'%A', b'.*', $wanted_re);
- $wanted_re = str_replace(b'%w', b'\s*', $wanted_re);
- $wanted_re = str_replace(b'%i', b'[+-]?\d+', $wanted_re);
- $wanted_re = str_replace(b'%d', b'\d+', $wanted_re);
- $wanted_re = str_replace(b'%x', b'[0-9a-fA-F]+', $wanted_re);
- $wanted_re = str_replace(b'%f', b'[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re);
- $wanted_re = str_replace(b'%c', b'.', $wanted_re);
+ $wanted_re = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $wanted_re);
+ $wanted_re = str_replace('%s', '[^\r\n]+', $wanted_re);
+ $wanted_re = str_replace('%S', '[^\r\n]*', $wanted_re);
+ $wanted_re = str_replace('%a', '.+', $wanted_re);
+ $wanted_re = str_replace('%A', '.*', $wanted_re);
+ $wanted_re = str_replace('%w', '\s*', $wanted_re);
+ $wanted_re = str_replace('%i', '[+-]?\d+', $wanted_re);
+ $wanted_re = str_replace('%d', '\d+', $wanted_re);
+ $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
+ $wanted_re = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re);
+ $wanted_re = str_replace('%c', '.', $wanted_re);
// %f allows two points "-.0.0" but that is the best *simple* expression
}
/* DEBUG YOUR REGEX HERE
@@ -1874,7 +1952,7 @@ COMMAND $cmd
print(str_repeat('=', 80) . "\n");
var_dump($output);
*/
- if (preg_match(b"/^$wanted_re\$/s", $output)) {
+ if (preg_match("/^$wanted_re\$/s", $output)) {
$passed = true;
if (!$cfg['keep']['php']) {
@unlink($test_file);
@@ -1889,6 +1967,12 @@ COMMAND $cmd
$info = " (warn: XFAIL section but test passes)";
}else {
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_pass']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'PASSED';
}
}
@@ -1896,8 +1980,8 @@ COMMAND $cmd
} else {
- $wanted = (binary) trim($section_text['EXPECT']);
- $wanted = preg_replace(b'/\r\n/',b"\n", $wanted);
+ $wanted = trim($section_text['EXPECT']);
+ $wanted = preg_replace('/\r\n/',"\n", $wanted);
show_file_block('exp', $wanted);
// compare and leave on success
@@ -1918,6 +2002,12 @@ COMMAND $cmd
$info = " (warn: XFAIL section but test passes)";
}else {
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
+ if ($JUNIT) {
+ $JUNIT['test_total']++;
+ $JUNIT['test_pass']++;
+ $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return 'PASSED';
}
}
@@ -1929,8 +2019,8 @@ COMMAND $cmd
// Test failed so we need to report details.
if ($failed_headers) {
$passed = false;
- $wanted = (binary) $wanted_headers . b"\n--HEADERS--\n" . (binary) $wanted;
- $output = (binary) $output_headers . b"\n--HEADERS--\n" . (binary) $output;
+ $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;
@@ -1948,7 +2038,7 @@ COMMAND $cmd
if (!$passed) {
if (isset($section_text['XFAIL'])) {
$restype[] = 'XFAIL';
- $info = ' XFAIL REASON: ' . $section_text['XFAIL'];
+ $info = ' XFAIL REASON: ' . rtrim($section_text['XFAIL']);
} else {
$restype[] = 'FAIL';
}
@@ -1957,12 +2047,12 @@ COMMAND $cmd
if (!$passed) {
// write .exp
- if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, (binary) $wanted, FILE_BINARY) === false) {
+ if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, $wanted, FILE_BINARY) === false) {
error("Cannot create expected test output - $exp_filename");
}
// write .out
- if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, (binary) $output, FILE_BINARY) === false) {
+ if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, $output, FILE_BINARY) === false) {
error("Cannot create test output - $output_filename");
}
@@ -1972,12 +2062,12 @@ COMMAND $cmd
$diff = "# original source file: $shortname\n" . $diff;
}
show_file_block('diff', $diff);
- if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, (binary) $diff, FILE_BINARY) === false) {
+ if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, $diff, FILE_BINARY) === false) {
error("Cannot create test diff - $diff_filename");
}
// write .sh
- if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, b"#!/bin/sh
+ if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, "#!/bin/sh
{$cmd}
", FILE_BINARY) === false) {
@@ -1986,7 +2076,7 @@ COMMAND $cmd
chmod($sh_filename, 0755);
// write .log
- if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, b"
+ if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "
---- EXPECTED OUTPUT
$wanted
---- ACTUAL OUTPUT
@@ -2013,6 +2103,23 @@ $output
if (isset($old_php)) {
$php = $old_php;
}
+
+ if ($JUNIT) {
+ $JUNIT['result_xml'] .= '<testcase classname="'. str_replace($cwd . '/', '', $tested_file).'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+ $JUNIT['test_total']++;
+ if (in_array('XFAIL', $restype)) {
+ $JUNIT['test_pass']++;
+ }
+ elseif (in_array('FAIL', $restype)) {
+ $JUNIT['test_fail']++;
+ $JUNIT['result_xml'] .= '<failure type="'.$restype[0].'ED" message="'.$info.'"><![CDATA['."\n".preg_replace('/\e/', '<esc>', $diff)."\n".']]></failure>'."\n";
+ }
+ else{
+ $JUNIT['test_error']++;
+ $JUNIT['result_xml'] .= '<error type="'.$restype[0].'ED" message="'.$info.'"><![CDATA['."\n".preg_replace('/\e/', '<esc>', $diff)."\n".']]></error>'."\n";
+ }
+ $JUNIT['result_xml'] .= '</testcase>'."\n";
+ }
return $restype[0] . 'ED';
}
@@ -2020,9 +2127,9 @@ $output
function comp_line($l1, $l2, $is_reg)
{
if ($is_reg) {
- return preg_match(b'/^'. (binary) $l1 . b'$/s', (binary) $l2);
+ return preg_match('/^'. $l1 . '$/s', $l2);
} else {
- return !strcmp((binary) $l1, (binary) $l2);
+ return !strcmp($l1, $l2);
}
}
@@ -2088,14 +2195,14 @@ function generate_array_diff($ar1, $ar2, $is_reg, $w)
$c2 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2+1, $cnt1, $cnt2, 10);
if ($c1 > $c2) {
- $old1[$idx1] = (binary) sprintf("%03d- ", $idx1+1) . $w[$idx1++];
+ $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++];
$last = 1;
} else if ($c2 > 0) {
- $old2[$idx2] = (binary) sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
+ $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
$last = 2;
} else {
- $old1[$idx1] = (binary) sprintf("%03d- ", $idx1+1) . $w[$idx1++];
- $old2[$idx2] = (binary) sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
+ $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++];
+ $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
}
}
}
@@ -2125,11 +2232,11 @@ function generate_array_diff($ar1, $ar2, $is_reg, $w)
}
while ($idx1 < $cnt1) {
- $diff[] = (binary) sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
+ $diff[] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
}
while ($idx2 < $cnt2) {
- $diff[] = (binary) sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
+ $diff[] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
}
return $diff;
@@ -2137,12 +2244,12 @@ function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff($wanted, $wanted_re, $output)
{
- $w = explode(b"\n", $wanted);
- $o = explode(b"\n", $output);
- $r = is_null($wanted_re) ? $w : explode(b"\n", $wanted_re);
+ $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);
- return implode(b"\r\n", $diff);
+ return implode("\r\n", $diff);
}
function error($message)
@@ -2293,6 +2400,18 @@ Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
';
$failed_test_summary = '';
+ if (count($PHP_FAILED_TESTS['XFAILED'])) {
+ $failed_test_summary .= '
+=====================================================================
+EXPECTED FAILED TEST SUMMARY
+---------------------------------------------------------------------
+';
+ foreach ($PHP_FAILED_TESTS['XFAILED'] as $failed_test_data) {
+ $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
+ }
+ $failed_test_summary .= "=====================================================================\n";
+ }
+
if (count($PHP_FAILED_TESTS['BORKED'])) {
$failed_test_summary .= '
=====================================================================
@@ -2317,18 +2436,6 @@ FAILED TEST SUMMARY
}
$failed_test_summary .= "=====================================================================\n";
}
- if (count($PHP_FAILED_TESTS['XFAILED'])) {
- $failed_test_summary .= '
-=====================================================================
-EXPECTED FAILED TEST SUMMARY
----------------------------------------------------------------------
-';
- foreach ($PHP_FAILED_TESTS['XFAILED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
- }
- $failed_test_summary .= "=====================================================================\n";
- }
-
if (count($PHP_FAILED_TESTS['WARNED'])) {
$failed_test_summary .= '
=====================================================================
@@ -2403,39 +2510,57 @@ function show_summary()
function show_redirect_start($tests, $tested, $tested_file)
{
- global $html_output, $html_file;
+ global $html_output, $html_file, $line_length, $SHOW_ONLY_GROUPS;
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";
+ if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) {
+ echo "REDIRECT $tests ($tested [$tested_file]) begin\n";
+ } else {
+ // Write over the last line to avoid random trailing chars on next echo
+ echo str_repeat(" ", $line_length), "\r";
+ }
}
function show_redirect_ends($tests, $tested, $tested_file)
{
- global $html_output, $html_file;
+ global $html_output, $html_file, $line_length, $SHOW_ONLY_GROUPS;
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";
+ if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) {
+ echo "REDIRECT $tests ($tested [$tested_file]) done\n";
+ } else {
+ // Write over the last line to avoid random trailing chars on next echo
+ echo str_repeat(" ", $line_length), "\r";
+ }
}
function show_test($test_idx, $shortname)
{
global $test_cnt;
+ global $line_length;
- echo "TEST $test_idx/$test_cnt [$shortname]\r";
+ $str = "TEST $test_idx/$test_cnt [$shortname]\r";
+ $line_length = strlen($str);
+ echo $str;
flush();
}
function show_result($result, $tested, $tested_file, $extra = '', $temp_filenames = null)
{
- global $html_output, $html_file, $temp_target, $temp_urlbase;
+ global $html_output, $html_file, $temp_target, $temp_urlbase, $line_length, $SHOW_ONLY_GROUPS;
- echo "$result $tested [$tested_file] $extra\n";
+ if (!$SHOW_ONLY_GROUPS || in_array($result, $SHOW_ONLY_GROUPS)) {
+ echo "$result $tested [$tested_file] $extra\n";
+ } else {
+ // Write over the last line to avoid random trailing chars on next echo
+ echo str_repeat(" ", $line_length), "\r";
+ }
if ($html_output) {
@@ -2482,6 +2607,20 @@ function show_result($result, $tested, $tested_file, $extra = '', $temp_filename
}
}
+function save_junit_xml() {
+ global $JUNIT;
+ $JUNIT['finished_at'] = microtime(true);
+ $JUNIT['execution_time']= number_format(($JUNIT['finished_at']-$JUNIT['started_at']), 2);
+ $JUNIT['result_xml'] = '<?xml version="1.0" encoding="UTF-8"?>'."\n".
+ '<testsuites>'."\n".
+ '<testsuite name="php-src" tests="'.$JUNIT['test_total'].'" failures="'.$JUNIT['test_fail'].'" errors="'.$JUNIT['test_error'].'" skip="'.$JUNIT['test_skip'].'" time="'.$JUNIT['execution_time'].'">'."\n".
+ $JUNIT['result_xml'].
+ '</testsuite>'."\n".
+ '</testsuites>';
+ fwrite($JUNIT['fp'], $JUNIT['result_xml']);
+}
+
+
/*
* Local variables:
* tab-width: 4