]> granicus.if.org Git - php/commitdiff
fixing run-tests.php for variables_order="GPCS"
authorMatt Ficken <mattficken@php.net>
Mon, 15 May 2017 09:19:05 +0000 (02:19 -0700)
committerMatt Ficken <mattficken@php.net>
Mon, 15 May 2017 09:19:05 +0000 (02:19 -0700)
run-tests.php

index 7f8653f1b329a8f67e082cabef512b863d1e7462..fbb664d809d246576e4bf20b8533cc878dab3d22 100755 (executable)
@@ -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 <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).
@@ -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, "<hr/>\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 .= '
 =====================================================================