From: Matt Ficken Date: Mon, 15 May 2017 09:19:05 +0000 (-0700) Subject: fixing run-tests.php for variables_order="GPCS" X-Git-Tag: php-7.2.0alpha2~15^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad67218954a3b78640c14c9720b797906d5e9133;p=php fixing run-tests.php for variables_order="GPCS" --- diff --git a/run-tests.php b/run-tests.php index 7f8653f1b3..fbb664d809 100755 --- a/run-tests.php +++ b/run-tests.php @@ -94,6 +94,28 @@ 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"); } @@ -456,10 +478,9 @@ function save_or_mail_results() $test_files = array(); $redir_tests = array(); $test_results = array(); -$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array(), 'SLOW' => array()); +$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array()); // If parameters given assume they represent selected tests to run. -$result_tests_file= false; $failed_tests_file= false; $pass_option_n = false; $pass_options = ''; @@ -475,7 +496,6 @@ $temp_target = null; $temp_urlbase = null; $conf_passed = null; $no_clean = false; -$slow_min_ms = INF; $cfgtypes = array('show', 'keep'); $cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp'); @@ -560,9 +580,6 @@ if (isset($argc) && $argc > 1) { case 'a': $failed_tests_file = fopen($argv[++$i], 'a+t'); break; - case 'W': - $result_tests_file = fopen($argv[++$i], 'w+t'); - break; case 'c': $conf_passed = $argv[++$i]; break; @@ -636,9 +653,6 @@ if (isset($argc) && $argc > 1) { $cfg['show'][$file] = true; } break; - case '--show-slow': - $slow_min_ms = $argv[++$i]; - break; case '--temp-source': $temp_source = $argv[++$i]; break; @@ -698,8 +712,6 @@ Options: -a Same as -w but append rather then truncating . - -W Write a list of all tests and their result status to . - -c Look for php.ini in directory or use as ini. -n Pass -n option to the php binary (Do not use a php.ini). @@ -756,9 +768,6 @@ Options: get written independent of the log format, however 'diff' only exists when a test fails. - --show-slow [n] - Show all tests that took longer than [n] milliseconds to run. - --no-clean Do not execute clean section if any. HELP; @@ -832,10 +841,6 @@ HELP; fclose($failed_tests_file); } - if ($result_tests_file) { - fclose($result_tests_file); - } - compute_summary(); if ($html_output) { fwrite($html_file, "
\n" . get_summary(false, true)); @@ -969,10 +974,6 @@ if ($failed_tests_file) { fclose($failed_tests_file); } -if ($result_tests_file) { - fclose($result_tests_file); -} - // Summarize results if (0 == count($test_results)) { @@ -1174,7 +1175,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS function run_all_tests($test_files, $env, $redir_tested = null) { - global $test_results, $failed_tests_file, $result_tests_file, $php, $test_idx; + global $test_results, $failed_tests_file, $php, $test_idx; foreach($test_files as $name) { @@ -1197,9 +1198,6 @@ function run_all_tests($test_files, $env, $redir_tested = null) if ($failed_tests_file && ($result == 'XFAILED' || $result == 'FAILED' || $result == 'WARNED' || $result == 'LEAKED')) { fwrite($failed_tests_file, "$index\n"); } - if ($result_tests_file) { - fwrite($result_tests_file, "$result\t$index\n"); - } } } } @@ -1235,7 +1233,6 @@ function run_test($php, $file, $env) global $valgrind_version; global $SHOW_ONLY_GROUPS; global $no_file_cache; - global $slow_min_ms; $temp_filenames = null; $org_file = $file; @@ -1920,21 +1917,10 @@ COMMAND $cmd "; junit_start_timer($shortname); - $startTime = microtime(true); $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null, $captureStdIn, $captureStdOut, $captureStdErr); junit_finish_timer($shortname); - $time = microtime(true) - $startTime; - if ($time * 1000 >= $slow_min_ms) { - $PHP_FAILED_TESTS['SLOW'][] = array( - 'name' => $file, - 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [$tested_file]", - 'output' => '', - 'diff' => '', - 'info' => $time, - ); - } if (array_key_exists('CLEAN', $section_text) && (!$no_clean || $cfg['keep']['clean'])) { @@ -2516,22 +2502,6 @@ Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . ' '; $failed_test_summary = ''; - if (count($PHP_FAILED_TESTS['SLOW'])) { - usort($PHP_FAILED_TESTS['SLOW'], function($a, $b) { - return $a['info'] < $b['info'] ? 1 : -1; - }); - - $failed_test_summary .= ' -===================================================================== -SLOW TEST SUMMARY ---------------------------------------------------------------------- -'; - foreach ($PHP_FAILED_TESTS['SLOW'] as $failed_test_data) { - $failed_test_summary .= sprintf('(%.3f s) ', $failed_test_data['info']) . $failed_test_data['test_name'] . "\n"; - } - $failed_test_summary .= "=====================================================================\n"; - } - if (count($PHP_FAILED_TESTS['XFAILED'])) { $failed_test_summary .= ' =====================================================================