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");
}
$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 = '';
$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');
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;
$cfg['show'][$file] = true;
}
break;
- case '--show-slow':
- $slow_min_ms = $argv[++$i];
- break;
case '--temp-source':
$temp_source = $argv[++$i];
break;
-a <file> Same as -w but append rather then truncating <file>.
- -W <file> Write a list of all tests and their result status to <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).
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;
fclose($failed_tests_file);
}
- if ($result_tests_file) {
- fclose($result_tests_file);
- }
-
compute_summary();
if ($html_output) {
fwrite($html_file, "<hr/>\n" . get_summary(false, true));
fclose($failed_tests_file);
}
-if ($result_tests_file) {
- fclose($result_tests_file);
-}
-
// Summarize results
if (0 == count($test_results)) {
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) {
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");
- }
}
}
}
global $valgrind_version;
global $SHOW_ONLY_GROUPS;
global $no_file_cache;
- global $slow_min_ms;
$temp_filenames = null;
$org_file = $file;
";
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'])) {
';
$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 .= '
=====================================================================