mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Revert "fixing run-tests.php for variables_order="GPCS""
This reverts commit c1d5718697
.
The commit seems to be inappropriate as it contains parts from master,
which have nothing to do with the variables order issue. Obviously patch
applied to wrong branch or alike.
This commit is contained in:
parent
b067bda4cd
commit
8ec91086ee
168
run-tests.php
168
run-tests.php
@ -94,28 +94,6 @@ if (ob_get_level()) echo "Not all buffers were deleted.\n";
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$environment = isset($_ENV) ? $_ENV : array();
|
||||
// Note: php.ini-development sets variables_order="GPCS" not "EGPCS", in which case $_ENV is NOT populated.
|
||||
// detect and handle this case, or die or warn
|
||||
if (empty($environment)) {
|
||||
// not documented, but returns array of all environment variables
|
||||
$environment = getenv();
|
||||
}
|
||||
if (empty($environment['TEMP'])) {
|
||||
$environment['TEMP'] = sys_get_temp_dir();
|
||||
|
||||
if (empty($environment['TEMP'])) {
|
||||
// for example, OpCache on Windows will fail in this case because child processes (for tests) will not get
|
||||
// a TEMP variable, so GetTempPath() will fallback to c:\windows, while GetTempPath() will return %TEMP% for parent
|
||||
// (likely a different path). The parent will initialize the OpCache in that path, and child will fail to reattach to
|
||||
// the OpCache because it will be using the wrong path.
|
||||
die("TEMP environment is NOT set");
|
||||
} else if (count($environment)==1) {
|
||||
// not having other environment variables, only having TEMP, is probably ok, but strange and may make a
|
||||
// difference in the test pass rate, so warn the user.
|
||||
echo "WARNING: Only 1 environment variable will be available to tests(TEMP environment variable)".PHP_EOL;
|
||||
}
|
||||
}
|
||||
//
|
||||
if ((substr(PHP_OS, 0, 3) == "WIN") && empty($environment["SystemRoot"])) {
|
||||
$environment["SystemRoot"] = getenv("SystemRoot");
|
||||
}
|
||||
@ -239,7 +217,7 @@ $ini_overwrites = array(
|
||||
'display_startup_errors=1',
|
||||
'log_errors=0',
|
||||
'html_errors=0',
|
||||
'track_errors=0',
|
||||
'track_errors=1',
|
||||
'report_memleaks=1',
|
||||
'report_zend_debug=0',
|
||||
'docref_root=',
|
||||
@ -258,7 +236,7 @@ $ini_overwrites = array(
|
||||
|
||||
$no_file_cache = '-d opcache.file_cache= -d opcache.file_cache_only=0';
|
||||
|
||||
function write_information()
|
||||
function write_information($show_html)
|
||||
{
|
||||
global $cwd, $php, $php_cgi, $phpdbg, $php_info, $user_tests, $ini_overwrites, $pass_options, $exts_to_test, $leak_check, $valgrind_header, $no_file_cache;
|
||||
|
||||
@ -301,7 +279,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n"
|
||||
@unlink($info_file);
|
||||
|
||||
// load list of enabled extensions
|
||||
save_text($info_file, '<?php echo str_replace("Zend OPcache", "opcache", implode(",", get_loaded_extensions())); ?>');
|
||||
save_text($info_file, '<?php echo str_replace("Zend OPcache", "opcache", join(",", get_loaded_extensions())); ?>');
|
||||
$exts_to_test = explode(',',`$php $pass_options $info_params $no_file_cache "$info_file"`);
|
||||
// check for extensions that need special handling and regenerate
|
||||
$info_params_ex = array(
|
||||
@ -346,7 +324,7 @@ define('TRAVIS_CI' , (bool) getenv('TRAVIS'));
|
||||
function save_or_mail_results()
|
||||
{
|
||||
global $sum_results, $just_save_results, $failed_test_summary,
|
||||
$PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file;
|
||||
$PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression;
|
||||
|
||||
/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */
|
||||
if (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
|
||||
@ -457,7 +435,7 @@ function save_or_mail_results()
|
||||
$failed_tests_data .= $sep . "PHPINFO" . $sep;
|
||||
$failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null');
|
||||
|
||||
if (($just_save_results || !mail_qa_team($failed_tests_data, $status)) && !TRAVIS_CI) {
|
||||
if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) {
|
||||
file_put_contents($output_file, $failed_tests_data);
|
||||
|
||||
if (!$just_save_results) {
|
||||
@ -485,8 +463,13 @@ $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 && in_array("compress.zlib", stream_get_filters())) {
|
||||
$output_file = 'compress.zlib://' . $output_file . '.gz';
|
||||
}
|
||||
|
||||
$just_save_results = false;
|
||||
$leak_check = false;
|
||||
$html_output = false;
|
||||
@ -511,7 +494,7 @@ foreach($cfgtypes as $type) {
|
||||
|
||||
if (getenv('TEST_PHP_ARGS')) {
|
||||
|
||||
if (!isset($argc, $argv) || !$argc) {
|
||||
if (!isset($argc) || !$argc || !isset($argv)) {
|
||||
$argv = array(__FILE__);
|
||||
}
|
||||
|
||||
@ -819,7 +802,7 @@ HELP;
|
||||
if ($test_cnt) {
|
||||
putenv('NO_INTERACTION=1');
|
||||
verify_config();
|
||||
write_information();
|
||||
write_information($html_output);
|
||||
usort($test_files, "test_sort");
|
||||
$start_time = time();
|
||||
|
||||
@ -867,7 +850,7 @@ HELP;
|
||||
}
|
||||
|
||||
verify_config();
|
||||
write_information();
|
||||
write_information($html_output);
|
||||
|
||||
// Compile a list of all test files (*.phpt).
|
||||
$test_files = array();
|
||||
@ -899,7 +882,7 @@ foreach ($user_tests as $dir) {
|
||||
|
||||
function find_files($dir, $is_ext_dir = false, $ignore = false)
|
||||
{
|
||||
global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped;
|
||||
global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested;
|
||||
|
||||
$o = opendir($dir) or error("cannot open directory: $dir");
|
||||
|
||||
@ -1003,7 +986,7 @@ exit(0);
|
||||
// Send Email to QA Team
|
||||
//
|
||||
|
||||
function mail_qa_team($data, $status = false)
|
||||
function mail_qa_team($data, $compression, $status = false)
|
||||
{
|
||||
$url_bits = parse_url(QA_SUBMISSION_PAGE);
|
||||
|
||||
@ -1092,7 +1075,7 @@ function error_report($testname, $logname, $tested)
|
||||
}
|
||||
}
|
||||
|
||||
function system_with_timeout($commandline, $env = null, $stdin = null, $captureStdIn = true, $captureStdOut = true, $captureStdErr = true)
|
||||
function system_with_timeout($commandline, $env = null, $stdin = null)
|
||||
{
|
||||
global $leak_check, $cwd;
|
||||
|
||||
@ -1103,29 +1086,21 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS
|
||||
$bin_env[$key] = $value;
|
||||
}
|
||||
|
||||
$descriptorspec = array();
|
||||
if ($captureStdIn) {
|
||||
$descriptorspec[0] = array('pipe', 'r');
|
||||
}
|
||||
if ($captureStdOut) {
|
||||
$descriptorspec[1] = array('pipe', 'w');
|
||||
}
|
||||
if ($captureStdErr) {
|
||||
$descriptorspec[2] = array('pipe', 'w');
|
||||
}
|
||||
$proc = proc_open($commandline, $descriptorspec, $pipes, $cwd, $bin_env, array('suppress_errors' => true, 'binary_pipes' => true));
|
||||
$proc = proc_open($commandline, array(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => array('pipe', 'w'),
|
||||
2 => array('pipe', 'w')
|
||||
), $pipes, $cwd, $bin_env, array('suppress_errors' => true, 'binary_pipes' => true));
|
||||
|
||||
if (!$proc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($captureStdIn) {
|
||||
if (!is_null($stdin)) {
|
||||
fwrite($pipes[0], $stdin);
|
||||
}
|
||||
fclose($pipes[0]);
|
||||
unset($pipes[0]);
|
||||
if (!is_null($stdin)) {
|
||||
fwrite($pipes[0], $stdin);
|
||||
}
|
||||
fclose($pipes[0]);
|
||||
unset($pipes[0]);
|
||||
|
||||
$timeout = $leak_check ? 300 : (isset($env['TEST_TIMEOUT']) ? $env['TEST_TIMEOUT'] : 60);
|
||||
|
||||
@ -1145,13 +1120,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS
|
||||
proc_terminate($proc, 9);
|
||||
return $data;
|
||||
} else if ($n > 0) {
|
||||
if ($captureStdOut) {
|
||||
$line = fread($pipes[1], 8192);
|
||||
} elseif ($captureStdErr) {
|
||||
$line = fread($pipes[2], 8192);
|
||||
} else {
|
||||
$line = '';
|
||||
}
|
||||
$line = fread($pipes[1], 8192);
|
||||
if (strlen($line) == 0) {
|
||||
/* EOF */
|
||||
break;
|
||||
@ -1169,13 +1138,13 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS
|
||||
$data .= "\nTermsig=" . ($stat["exitcode"] - 128) . "\n";
|
||||
}
|
||||
|
||||
proc_close($proc);
|
||||
$code = proc_close($proc);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function run_all_tests($test_files, $env, $redir_tested = null)
|
||||
{
|
||||
global $test_results, $failed_tests_file, $php, $test_idx;
|
||||
global $test_results, $failed_tests_file, $php, $test_cnt, $test_idx;
|
||||
|
||||
foreach($test_files as $name) {
|
||||
|
||||
@ -1226,11 +1195,12 @@ function show_file_block($file, $block, $section = null)
|
||||
//
|
||||
function run_test($php, $file, $env)
|
||||
{
|
||||
global $log_format, $ini_overwrites, $cwd, $PHP_FAILED_TESTS;
|
||||
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 $valgrind_version;
|
||||
global $JUNIT;
|
||||
global $SHOW_ONLY_GROUPS;
|
||||
global $no_file_cache;
|
||||
$temp_filenames = null;
|
||||
@ -1339,7 +1309,7 @@ TEST $file
|
||||
unset($section_text['FILEEOF']);
|
||||
}
|
||||
|
||||
foreach (array( 'FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX' ) as $prefix) {
|
||||
foreach (array( 'FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX' ) as $prefix) {
|
||||
$key = $prefix . '_EXTERNAL';
|
||||
|
||||
if (@count($section_text[$key]) == 1) {
|
||||
@ -1381,21 +1351,6 @@ TEST $file
|
||||
return 'BORKED';
|
||||
}
|
||||
|
||||
if (isset($section_text['CAPTURE_STDIO'])) {
|
||||
$captureStdIn = stripos($section_text['CAPTURE_STDIO'], 'STDIN') !== false;
|
||||
$captureStdOut = stripos($section_text['CAPTURE_STDIO'], 'STDOUT') !== false;
|
||||
$captureStdErr = stripos($section_text['CAPTURE_STDIO'], 'STDERR') !== false;
|
||||
} else {
|
||||
$captureStdIn = true;
|
||||
$captureStdOut = true;
|
||||
$captureStdErr = true;
|
||||
}
|
||||
if ($captureStdOut && $captureStdErr) {
|
||||
$cmdRedirect = ' 2>&1';
|
||||
} else {
|
||||
$cmdRedirect = '';
|
||||
}
|
||||
|
||||
$tested = trim($section_text['TEST']);
|
||||
|
||||
/* For GET/POST/PUT tests, check if cgi sapi is available and if it is, use it. */
|
||||
@ -1551,7 +1506,7 @@ TEST $file
|
||||
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 implode(",", get_loaded_extensions());'`);
|
||||
$loaded = explode(",", `$php -n -r 'echo join(",", get_loaded_extensions());'`);
|
||||
foreach ($extensions as $req_ext) {
|
||||
if (!in_array($req_ext, $loaded)) {
|
||||
if ($req_ext == 'opcache') {
|
||||
@ -1616,6 +1571,10 @@ TEST $file
|
||||
show_result('SKIP', $tested, $tested_file, '', $temp_filenames);
|
||||
}
|
||||
|
||||
if (isset($old_php)) {
|
||||
$php = $old_php;
|
||||
}
|
||||
|
||||
if (!$cfg['keep']['skip']) {
|
||||
@unlink($test_skipif);
|
||||
}
|
||||
@ -1644,9 +1603,9 @@ TEST $file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!extension_loaded("zlib")
|
||||
&& ( array_key_exists("GZIP_POST", $section_text)
|
||||
&& ( array_key_exists("GZIP_POST", $section_text)
|
||||
|| array_key_exists("DEFLATE_POST", $section_text))
|
||||
) {
|
||||
$message = "ext/zlib required";
|
||||
@ -1663,7 +1622,7 @@ TEST $file
|
||||
$IN_REDIRECT['dir'] = realpath(dirname($file));
|
||||
$IN_REDIRECT['prefix'] = trim($section_text['TEST']);
|
||||
|
||||
if (!empty($IN_REDIRECT['TESTS'])) {
|
||||
if (count($IN_REDIRECT['TESTS']) == 1) {
|
||||
|
||||
if (is_array($org_file)) {
|
||||
$test_files[] = $org_file[1];
|
||||
@ -1795,7 +1754,7 @@ TEST $file
|
||||
}
|
||||
|
||||
save_text($tmp_post, $request);
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\"$cmdRedirect < \"$tmp_post\"";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
|
||||
|
||||
} elseif (array_key_exists('PUT', $section_text) && !empty($section_text['PUT'])) {
|
||||
|
||||
@ -1829,7 +1788,7 @@ TEST $file
|
||||
}
|
||||
|
||||
save_text($tmp_post, $request);
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\"$cmdRedirect < \"$tmp_post\"";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
|
||||
|
||||
} else if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
|
||||
|
||||
@ -1846,7 +1805,7 @@ TEST $file
|
||||
$env['CONTENT_LENGTH'] = $content_length;
|
||||
}
|
||||
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\"$cmdRedirect < \"$tmp_post\"";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
|
||||
|
||||
} else if (array_key_exists('GZIP_POST', $section_text) && !empty($section_text['GZIP_POST'])) {
|
||||
|
||||
@ -1861,7 +1820,7 @@ TEST $file
|
||||
$env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
||||
$env['CONTENT_LENGTH'] = $content_length;
|
||||
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\"$cmdRedirect < \"$tmp_post\"";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
|
||||
|
||||
} else if (array_key_exists('DEFLATE_POST', $section_text) && !empty($section_text['DEFLATE_POST'])) {
|
||||
$post = trim($section_text['DEFLATE_POST']);
|
||||
@ -1874,7 +1833,7 @@ TEST $file
|
||||
$env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
||||
$env['CONTENT_LENGTH'] = $content_length;
|
||||
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\"$cmdRedirect < \"$tmp_post\"";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
|
||||
|
||||
} else {
|
||||
|
||||
@ -1882,7 +1841,7 @@ TEST $file
|
||||
$env['CONTENT_TYPE'] = '';
|
||||
$env['CONTENT_LENGTH'] = '';
|
||||
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" $args$cmdRedirect";
|
||||
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" $args 2>&1";
|
||||
}
|
||||
|
||||
if ($leak_check) {
|
||||
@ -1918,7 +1877,7 @@ COMMAND $cmd
|
||||
|
||||
junit_start_timer($shortname);
|
||||
|
||||
$out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null, $captureStdIn, $captureStdOut, $captureStdErr);
|
||||
$out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
|
||||
|
||||
junit_finish_timer($shortname);
|
||||
|
||||
@ -1960,11 +1919,12 @@ COMMAND $cmd
|
||||
$output = preg_replace("/\r\n/", "\n", trim($out));
|
||||
|
||||
/* when using CGI, strip the headers from the output */
|
||||
$headers = array();
|
||||
$headers = "";
|
||||
|
||||
if (!empty($uses_cgi) && preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $out, $match)) {
|
||||
$output = trim($match[2]);
|
||||
$rh = preg_split("/[\n\r]+/", $match[1]);
|
||||
$headers = array();
|
||||
|
||||
foreach ($rh as $line) {
|
||||
if (strpos($line, ':') !== false) {
|
||||
@ -1989,23 +1949,26 @@ COMMAND $cmd
|
||||
}
|
||||
}
|
||||
|
||||
$org_headers = $headers;
|
||||
$headers = array();
|
||||
$output_headers = array();
|
||||
|
||||
foreach($want as $k => $v) {
|
||||
|
||||
if (isset($headers[$k])) {
|
||||
$output_headers[] = $k . ': ' . $headers[$k];
|
||||
if (isset($org_headers[$k])) {
|
||||
$headers = $org_headers[$k];
|
||||
$output_headers[] = $k . ': ' . $org_headers[$k];
|
||||
}
|
||||
|
||||
if (!isset($headers[$k]) || $headers[$k] != $v) {
|
||||
if (!isset($org_headers[$k]) || $org_headers[$k] != $v) {
|
||||
$failed_headers = true;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($wanted_headers);
|
||||
$wanted_headers = implode("\n", $wanted_headers);
|
||||
$wanted_headers = join("\n", $wanted_headers);
|
||||
ksort($output_headers);
|
||||
$output_headers = implode("\n", $output_headers);
|
||||
$output_headers = join("\n", $output_headers);
|
||||
}
|
||||
|
||||
show_file_block('out', $output);
|
||||
@ -2095,6 +2058,9 @@ COMMAND $cmd
|
||||
if (!$cfg['keep']['php']) {
|
||||
@unlink($test_file);
|
||||
}
|
||||
if (isset($old_php)) {
|
||||
$php = $old_php;
|
||||
}
|
||||
|
||||
if (!$leaked && !$failed_headers) {
|
||||
if (isset($section_text['XFAIL'] )) {
|
||||
@ -2122,6 +2088,10 @@ COMMAND $cmd
|
||||
@unlink($test_file);
|
||||
}
|
||||
|
||||
if (isset($old_php)) {
|
||||
$php = $old_php;
|
||||
}
|
||||
|
||||
if (!$leaked && !$failed_headers) {
|
||||
if (isset($section_text['XFAIL'] )) {
|
||||
$warn = true;
|
||||
@ -2221,6 +2191,10 @@ $output
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($old_php)) {
|
||||
$php = $old_php;
|
||||
}
|
||||
|
||||
$diff = empty($diff) ? '' : preg_replace('/\e/', '<esc>', $diff);
|
||||
|
||||
junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
|
||||
@ -2281,8 +2255,8 @@ function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, $cnt2, $
|
||||
|
||||
function generate_array_diff($ar1, $ar2, $is_reg, $w)
|
||||
{
|
||||
$idx1 = 0; $cnt1 = @count($ar1);
|
||||
$idx2 = 0; $cnt2 = @count($ar2);
|
||||
$idx1 = 0; $ofs1 = 0; $cnt1 = @count($ar1);
|
||||
$idx2 = 0; $ofs2 = 0; $cnt2 = @count($ar2);
|
||||
$diff = array();
|
||||
$old1 = array();
|
||||
$old2 = array();
|
||||
@ -2300,8 +2274,10 @@ function generate_array_diff($ar1, $ar2, $is_reg, $w)
|
||||
|
||||
if ($c1 > $c2) {
|
||||
$old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++];
|
||||
$last = 1;
|
||||
} else if ($c2 > 0) {
|
||||
$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++];
|
||||
@ -2437,7 +2413,7 @@ function compute_summary()
|
||||
$sum_results['SKIPPED'] += $ignored_by_ext;
|
||||
$percent_results = array();
|
||||
|
||||
foreach ($sum_results as $v => $n) {
|
||||
while (list($v, $n) = each($sum_results)) {
|
||||
$percent_results[$v] = (100.0 * $n) / $n_total;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user