From c7d1c14b5c932670091eb85719b3dc28db55e383 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Mon, 9 Jul 2018 00:56:45 -0300 Subject: [PATCH] Small tweaks to php scripts --- run-tests.php | 12 +-- server-tests.php | 244 +++++++++++++++++++++++------------------------ 2 files changed, 128 insertions(+), 128 deletions(-) diff --git a/run-tests.php b/run-tests.php index e7f908c2e88e6..c47770ca066cc 100644 --- a/run-tests.php +++ b/run-tests.php @@ -89,7 +89,7 @@ error_reporting(E_ALL); -$environment = isset($_ENV) ? $_ENV : array(); +$environment = $_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)) { @@ -1028,7 +1028,7 @@ function mail_qa_team($data, $status = false) { $url_bits = parse_url(QA_SUBMISSION_PAGE); - if (($proxy = getenv('http_proxy'))) { + if ($proxy = getenv('http_proxy')) { $proxy = parse_url($proxy); $path = $url_bits['host'].$url_bits['path']; $host = $proxy['host']; @@ -1148,7 +1148,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS unset($pipes[0]); } - $timeout = $valgrind ? 300 : (isset($env['TEST_TIMEOUT']) ? $env['TEST_TIMEOUT'] : 60); + $timeout = $valgrind ? 300 : ($env['TEST_TIMEOUT'] ?? 60); while (true) { /* hide errors from interrupted syscalls */ @@ -1934,7 +1934,7 @@ function run_test($php, $file, $env) $hrtime = hrtime(); $startTime = $hrtime[0]*1000000000 + $hrtime[1]; - $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null, $captureStdIn, $captureStdOut, $captureStdErr); + $out = system_with_timeout($cmd, $env, $section_text['STDIN'] ?? null, $captureStdIn, $captureStdOut, $captureStdErr); junit_finish_timer($shortname); $hrtime = hrtime(); @@ -2215,7 +2215,7 @@ function run_test($php, $file, $env) error_report($file, $log_filename, $tested); } } - + if ($valgrind && $leaked && $cfg["show"]["mem"]) { show_file_block('mem', file_get_contents($memcheck_filename)); } @@ -2823,7 +2823,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag junit_suite_record($suite, 'test_total'); - $time = null !== $time ? $time : junit_get_timer($file_name); + $time = $time ?? junit_get_timer($file_name); junit_suite_record($suite, 'execution_time', $time); $escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8'); diff --git a/server-tests.php b/server-tests.php index ff4b9f6ffc3e7..4f51c88a7aae2 100755 --- a/server-tests.php +++ b/server-tests.php @@ -140,7 +140,7 @@ function mkpath($path,$mode = 0777) { function copyfiles($src,$new) { $d = dir($src); - while (($entry = $d->read())) { + while ($entry = $d->read()) { if (is_file("$src/$entry")) { copy("$src/$entry", "$new/$entry"); } @@ -154,14 +154,14 @@ function post_result_data($query,$data) $post = "php_test_data=" . urlencode(base64_encode(preg_replace("/[\\x00]/", "[0x0]", $data))); $r = new HTTPRequest($url,NULL,NULL,$post); return $this->response_headers['Status']=='200'; -} +} function execute($command, $args=NULL, $input=NULL, $cwd=NULL, $env=NULL) { $data = ""; - - if (gettype($args)=='array') { + + if (is_array($args)) { $args = join($args,' '); } $commandline = "$command $args"; @@ -179,7 +179,7 @@ function execute($command, $args=NULL, $input=NULL, $cwd=NULL, $env=NULL) return NULL; } } - + fclose($pipes[0]); while (true) { @@ -247,7 +247,7 @@ class HTTPRequest /* URL is the full url headers is assoc array of outgoing http headers - + options may include timeout proxy_host @@ -255,7 +255,7 @@ class HTTPRequest proxy_user proxy_pass method (GET|POST) - + post data is, well, post data. It is not processed so multipart stuff must be prepared before calling this (or add it to class) @@ -269,14 +269,14 @@ function HTTPRequest($URL, $headers=array(), $options=array(), $postdata=NULL) $this->postdata = &$postdata; $this->doRequest(); } - + function doRequest() { if (!$this->_validateUrl()) return; - - if (isset($this->options['timeout'])) + + if (isset($this->options['timeout'])) $this->timeout = (int)$this->options['timeout']; - + $this->_sendHTTP(); } @@ -295,7 +295,7 @@ function _validateUrl() $this->urlparts['path'] = '/'; return TRUE; } - + function _parseResponse() { if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $this->incoming_payload, $match)) { @@ -319,7 +319,7 @@ function _parseResponse() $this->errmsg = 'Invalid HTTP Response'; return FALSE; } - + function &_getRequest() { $fullpath = $this->urlparts['path']. @@ -343,13 +343,13 @@ function &_getRequest() $headertext .= "$k: $v\r\n"; } $method = trim($this->options['method'])?strtoupper(trim($this->options['method'])):'GET'; - $this->outgoing_payload = + $this->outgoing_payload = "$method $fullpath HTTP/1.0\r\n". $headertext."\r\n". $this->postdata; return $this->outgoing_payload; } - + function _sendHTTP() { $this->_getRequest(); @@ -357,7 +357,7 @@ function _sendHTTP() $port = $this->urlparts['port']; if (isset($this->options['proxy_host'])) { $host = $this->options['proxy_host']; - $port = isset($this->options['proxy_port'])?$this->options['proxy_port']:8080; + $port = $this->options['proxy_port'] ?? 8080; } // send if ($this->timeout > 0) { @@ -378,7 +378,7 @@ function _sendHTTP() $this->errmsg = "Error Sending Request Data to $host"; return NULL; } - + while ($data = fread($fp, 32768)) { $this->incoming_payload .= $data; } @@ -422,7 +422,7 @@ class testHarness { 'w' => array('TEST_WEB' ,'' ,0 ,'run tests via http'), 'x' => array('TEST_WEB_EXT' ,'file ext' ,'php' ,'http file extension to use') ); - + public $conf = array(); public $test_to_run = array(); public $test_files = array(); @@ -439,7 +439,7 @@ class testHarness { public $test_executable_iscgi = false; public $inisettings; // the test executables settings, used for web tests public $iswin32 = false; - + public $ddash = "====================================================================="; public $sdash = "---------------------------------------------------------------------"; @@ -463,7 +463,7 @@ class testHarness { 'error_append_string'=>'', 'auto_prepend_file'=>'', 'auto_append_file'=>'', - ); + ); public $env = array(); public $info_params = array(); @@ -472,7 +472,7 @@ function testHarness() { $this->checkRequirements(); $this->env = $_ENV; $this->removeSensitiveEnvVars(); - + $this->initializeConfiguration(); $this->parseArgs(); $this->setTestPaths(); @@ -490,13 +490,13 @@ function testHarness() { $this->conf['TEST_PHP_SRCDIR'] = str_replace('/','\\',$this->conf['TEST_PHP_SRCDIR']); $this->conf['TEST_BASE_PATH'] = str_replace('/','\\',$this->conf['TEST_BASE_PATH']); } - + if (!$this->conf['TEST_WEB'] && !is_executable($this->conf['TEST_PHP_EXECUTABLE'])) { $this->error("invalid PHP executable specified by TEST_PHP_EXECUTABLE = " . $this->conf['TEST_PHP_EXECUTABLE']); return false; } - + $this->getInstalledExtensions(); $this->getExecutableInfo(); $this->getExecutableIniSettings(); @@ -506,11 +506,11 @@ function testHarness() { // add TEST_PHP_SRCDIR to the include path, this facilitates // tests including files from src/tests //$this->ini_overwrites['include_path'] = $this->cwd.($this->iswin32?';.;':':.:').$this->exec_info['INCLUDE_PATH']; - + $params = array(); settings2array($this->ini_overwrites,$params); $this->info_params = settings2params($params); - + $this->contextHeader(); if ($this->conf['TEST_CONTEXT_INFO']) return; $this->loadFileList(); @@ -524,7 +524,7 @@ function getExecutableIniSettings() $out = $this->runscript(PHP_INI_SETTINGS_SCRIPT,true); $this->inisettings = unserialize($out); } - + function getExecutableInfo() { $out = $this->runscript(PHP_INFO_SCRIPT,true); @@ -540,7 +540,7 @@ function getExecutableInfo() } $this->exec_info = $info; } - + function getInstalledExtensions() { // get the list of installed extensions @@ -579,21 +579,21 @@ function runscript($script,$removeheaders=false,$cwd=NULL) } } - + // Use this function to do any displaying of text, so that // things can be over-written as necessary. - + function writemsg($msg) { - + echo $msg; - + } - + // Another wrapper function, this one should be used any time // a particular test passes or fails - + function showstatus($item, $status, $reason = '') { - + switch($status) { case 'PASSED': $this->writemsg("PASSED: $item ($reason)\n"); @@ -606,8 +606,8 @@ function showstatus($item, $status, $reason = '') { break; } } - - + + function help() { $usage = "usage: php run-tests.php [options]\n"; @@ -616,17 +616,17 @@ function help() } return $usage; } - + function parseArgs() { global $argc; global $argv; global $_SERVER; - + if (!isset($argv)) { $argv = $_SERVER['argv']; $argc = $_SERVER['argc']; } - + $conf = NULL; for ($i=1; $i<$argc;) { if ($argv[$i][0] != '-') continue; @@ -638,7 +638,7 @@ function parseArgs() { switch($opt) { case 'c': /* TODO: Implement configuraiton file */ - include($value); + include $value; if (!isset($conf)) { $this->writemsg("Invalid configuration file\n"); exit(1); @@ -655,13 +655,13 @@ function parseArgs() { if ($this->xargs[$opt][1] && isset($value)) $this->conf[$this->xargs[$opt][0]] = $value; else if (!$this->xargs[$opt][1]) - $this->conf[$this->xargs[$opt][0]] = isset($value)?$value:1; + $this->conf[$this->xargs[$opt][0]] = $value ?? 1; else $this->error("Invalid argument setting for argument $opt, should be [{$this->xargs[$opt][1]}]\n"); break; } } - + // set config into environment, this allows // executed tests to find out about the test // configurations. config file or args overwrite @@ -680,14 +680,14 @@ function removeSensitiveEnvVars() $this->env['SSH_AUTH_SOCK']='deleted'; $this->env['SSH_TTY']='deleted'; } - + function setEnvConfigVar($name) { if (isset($this->env[$name])) { $this->conf[$name] = $this->env[$name]; } } - + function initializeConfiguration() { foreach ($this->xargs as $arg=>$arg_info) { @@ -715,7 +715,7 @@ function setTestPaths() } } } - + function test_sort($a, $b) { $ta = strpos($a, "{$this->cwd}/tests")===0 ? 1 + (strpos($a, "{$this->cwd}/tests/run-test")===0 ? 1 : 0) : 0; $tb = strpos($b, "{$this->cwd}/tests")===0 ? 1 + (strpos($b, "{$this->cwd}/tests/run-test")===0 ? 1 : 0) : 0; @@ -745,7 +745,7 @@ function checkRequirements() { exit; } } - + // // Write test context information. // @@ -767,12 +767,12 @@ function contextHeader() foreach ($this->conf as $k=>$v) { $conf .= sprintf("%-20.s: %s\n",$k,$v); } - + $exeinfo = ''; if (!$this->conf['TEST_WEB']) $exeinfo = "CWD : {$this->cwd}\n". "PHP : {$this->conf['TEST_PHP_EXECUTABLE']}\n"; - + $this->writemsg("\n$this->ddash\n". "$exeinfo$info\n". "Test Harness Configuration:\n$conf\n". @@ -780,12 +780,12 @@ function contextHeader() "Test Dirs : $dirs\n". "$this->ddash\n"); } - + function loadFileList() { foreach ($this->test_dirs as $dir) { if (is_dir($dir)) { - $this->findFilesInDir($dir, ($dir == 'ext')); + $this->findFilesInDir($dir, $dir == 'ext'); } else { $this->test_files[] = $dir; } @@ -793,7 +793,7 @@ function loadFileList() usort($this->test_files,array($this,"test_sort")); $this->writemsg("found ".count($this->test_files)." files\n"); } - + function moveTestFiles() { if (!$this->conf['TEST_BASE_PATH'] || @@ -819,7 +819,7 @@ function moveTestFiles() } $this->test_files = $files; } - + function findFilesInDir($dir,$is_ext_dir=FALSE,$ignore=FALSE) { $skip = array('.', '..', 'CVS'); @@ -833,13 +833,13 @@ function findFilesInDir($dir,$is_ext_dir=FALSE,$ignore=FALSE) } $this->findFilesInDir("$dir/$name", FALSE, $ignore || $skip_ext); } - + // Cleanup any left-over tmp files from last run. if (substr($name, -4) == '.tmp') { @unlink("$dir/$name"); continue; } - + // Otherwise we're only interested in *.phpt files. if (substr($name, -5) == '.phpt') { if ($ignore) { @@ -852,7 +852,7 @@ function findFilesInDir($dir,$is_ext_dir=FALSE,$ignore=FALSE) } closedir($o); } - + function runHeader() { $this->writemsg("TIME START " . date('Y-m-d H:i:s', $this->start_time) . "\n".$this->ddash."\n"); @@ -862,14 +862,14 @@ function runHeader() $this->writemsg("Running all test files.\n"); } } - + function run() { $this->start_time = time(); $this->runHeader(); // Run selected tests. if (count($this->test_to_run)) { - + foreach($this->test_to_run as $name=>$runnable) { if(!preg_match("/\.phpt$/", $name)) continue; @@ -891,10 +891,10 @@ function summarizeResults() $this->writemsg("No tests were run.\n"); return; } - + $n_total = count($this->test_results); $n_total += $this->ignored_by_ext; - + $sum_results = array('PASSED'=>0, 'SKIPPED'=>0, 'FAILED'=>0); foreach ($this->test_results as $v) { $sum_results[$v]++; @@ -904,7 +904,7 @@ function summarizeResults() foreach ($sum_results as $v => $n) { $percent_results[$v] = (100.0 * $n) / $n_total; } - + $this->writemsg("\n".$this->ddash."\n". "TIME END " . date('Y-m-d H:i:s', $this->end_time) . "\n". $this->ddash."\n". @@ -920,7 +920,7 @@ function summarizeResults() $this->sdash."\n". "Time taken : " . sprintf("%4d seconds", $this->end_time - $this->start_time) . "\n". $this->ddash."\n"); - + $failed_test_summary = ''; if ($this->failed_tests) { $failed_test_summary .= "\n".$this->ddash."\n". @@ -930,7 +930,7 @@ function summarizeResults() } $failed_test_summary .= $this->ddash."\n"; } - + if ($failed_test_summary && !$this->conf['NO_PHPTEST_SUMMARY']) { $this->writemsg($failed_test_summary); } @@ -944,9 +944,9 @@ function summarizeResults() flush(); $user_input = fgets($fp, 10); $just_save_results = (strtolower($user_input[0]) == 's'); - + if ($just_save_results || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') { - /* + /* * Collect information about the host system for our report * Fetch phpinfo() output so that we can see the PHP environment * Make an archive of all the failed tests @@ -961,12 +961,12 @@ function summarizeResults() $user_email = trim(fgets($fp, 1024)); $user_email = str_replace("@", " at ", str_replace(".", " dot ", $user_email)); } - + $failed_tests_data = ''; $sep = "\n" . str_repeat('=', 80) . "\n"; - + $failed_tests_data .= $failed_test_summary . "\n"; - + if (array_sum($this->failed_tests)) { foreach ($this->failed_tests as $test_info) { $failed_tests_data .= $sep . $test_info['name']; @@ -978,7 +978,7 @@ function summarizeResults() } else { $status = "success"; } - + $failed_tests_data .= "\n" . $sep . 'BUILD ENVIRONMENT' . $sep; $failed_tests_data .= "OS:\n". PHP_OS. "\n\n"; $automake = $autoconf = $libtool = $compiler = 'N/A'; @@ -999,7 +999,7 @@ function summarizeResults() } } } - + $failed_tests_data .= "Automake:\n$automake\n"; $failed_tests_data .= "Autoconf:\n$autoconf\n"; $failed_tests_data .= "Libtool:\n$libtool\n"; @@ -1013,7 +1013,7 @@ function summarizeResults() $failed_tests_data .= $sep . "PHPINFO" . $sep; $failed_tests_data .= shell_exec($this->conf['TEST_PHP_EXECUTABLE'].' -dhtml_errors=0 -i'); - + $compression = 0; if ($just_save_results || @@ -1022,7 +1022,7 @@ function summarizeResults() $fp = fopen($output_file, "w"); fwrite($fp, $failed_tests_data); fclose($fp); - + if (!$just_save_results) echo "\nThe test script was unable to automatically send the report to PHP's QA Team\n"; echo "Please send ".$output_file." to ".PHP_QA_EMAIL." manually, thank you.\n"; @@ -1032,7 +1032,7 @@ function summarizeResults() } } } - + if($this->conf['REPORT_EXIT_STATUS'] and $sum_results['FAILED']) { exit(1); } @@ -1041,7 +1041,7 @@ function summarizeResults() function getINISettings(&$section_text) { $ini_settings = $this->ini_overwrites; - // Any special ini settings + // Any special ini settings // these may overwrite the test defaults... if (array_key_exists('INI', $section_text)) { settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings); @@ -1090,11 +1090,11 @@ function evalSettings($filename,$data) { // eval fails if no newline return eval("$data\n"); } - + function getENVSettings(&$section_text,$testfile) { $env = $this->env; - // Any special environment settings + // Any special environment settings // these may overwrite the test defaults... if (array_key_exists('ENV', $section_text)) { $sect = $this->evalSettings($testfile,$section_text['ENV']); @@ -1107,7 +1107,7 @@ function getENVSettings(&$section_text,$testfile) function getEvalTestSettings($section_text,$testfile) { $rq = array(); - // Any special environment settings + // Any special environment settings // these may overwrite the test defaults... if ($section_text) { $sect = $this->evalSettings($testfile,$section_text); @@ -1116,7 +1116,7 @@ function getEvalTestSettings($section_text,$testfile) } return $rq; } - + // // Load the sections of the test file. // @@ -1131,10 +1131,10 @@ function getSectionText($file) '_FILE' => $file, '_DIR' => realpath(dirname($file)), ); - + $fp = @fopen($file, "r") or $this->error("Cannot open test file: $file"); - + $section = ''; while (!feof($fp)) { $line = fgets($fp); @@ -1144,7 +1144,7 @@ function getSectionText($file) $section_text[$section] = ''; continue; } - + // Add to the section text. $section_text[$section] .= $line; } @@ -1199,13 +1199,13 @@ function getSkipReason($file,&$section_text,$docgi=false) if ($this->conf['TEST_PHP_DETAILED'] > 2) print "SKIPIF: [$output]\n"; if (preg_match("/^skip/i", $output)){ - - $reason = (preg_match("/^skip\s*(.+)\$/", $output)) ? preg_replace("/^skip\s*(.+)\$/", "\\1", $output) : FALSE; + + $reason = preg_match("/^skip\s*(.+)\$/", $output) ? preg_replace("/^skip\s*(.+)\$/", "\\1", $output) : FALSE; $this->showstatus($section_text['TEST'], 'SKIPPED', $reason); return 'SKIPPED'; } if (preg_match("/^info/i", $output)) { - $reason = (preg_match("/^info\s*(.+)\$/", $output)) ? preg_replace("/^info\s*(.+)\$/", "\\1", $output) : FALSE; + $reason = preg_match("/^info\s*(.+)\$/", $output) ? preg_replace("/^info\s*(.+)\$/", "\\1", $output) : FALSE; if ($reason) { $tested .= " (info: $reason)"; } @@ -1221,15 +1221,15 @@ function run_test($file) { if ($this->conf['TEST_PHP_DETAILED']) $this->writemsg("\n=================\nTEST $file\n"); - + $section_text = $this->getSectionText($file); - + if ($this->iswin32) $shortname = str_replace($this->conf['TEST_BASE_PATH'].'\\', '', $file); else $shortname = str_replace($this->conf['TEST_BASE_PATH'].'/', '', $file); $tested = $section_text['TEST']." [$shortname]"; - + if ($this->conf['TEST_WEB']) { $tmp_file = preg_replace('/\.phpt$/','.'.$this->conf['TEST_WEB_EXT'],$file); $uri = $this->conf['TEST_BASE_SCRIPT_NAME'].str_replace($this->conf['TEST_BASE_PATH'], '', $tmp_file); @@ -1238,19 +1238,19 @@ function run_test($file) $tmp_file = preg_replace('/\.phpt$/','.php',$file); } @unlink($tmp_file); - - // unlink old test results + + // unlink old test results @unlink(preg_replace('/\.phpt$/','.diff',$file)); @unlink(preg_replace('/\.phpt$/','.log',$file)); @unlink(preg_replace('/\.phpt$/','.exp',$file)); @unlink(preg_replace('/\.phpt$/','.out',$file)); - + if (!$this->conf['TEST_WEB']) { // Reset environment from any previous test. $env = $this->getENVSettings($section_text,$tmp_file); $ini_overwrites = $this->getINIParams($section_text); } - + // if this is a cgi test, prepare for it $query_string = ''; $havepost = array_key_exists('POST', $section_text) && !empty($section_text['POST']); @@ -1274,9 +1274,9 @@ function run_test($file) $request = $this->getEvalTestSettings(@$section_text['REQUEST'],$tmp_file); $headers = $this->getEvalTestSettings(@$section_text['HEADERS'],$tmp_file); - $method = isset($request['method'])?$request['method']:$havepost?'POST':'GET'; + $method = $request['method'] ?? $havepost ? 'POST' : 'GET'; $query_string = $haveget?$section_text['GET']:''; - + $options = array(); $options['method']=$method; if (isset($this->conf['timeout'])) $options['timeout'] = $this->conf['timeout']; @@ -1284,7 +1284,7 @@ function run_test($file) if (isset($this->conf['proxy_port'])) $options['proxy_port'] = $this->conf['proxy_port']; if (isset($this->conf['proxy_user'])) $options['proxy_user'] = $this->conf['proxy_user']; if (isset($this->conf['proxy_pass'])) $options['proxy_pass'] = $this->conf['proxy_pass']; - + $post = $havepost?$section_text['POST']:NULL; $url = $this->conf['TEST_SERVER_URL']; if (isset($request['SCRIPT_NAME'])) @@ -1303,7 +1303,7 @@ function run_test($file) $this->writemsg("\nURL = $url\n"); } else if ($do_cgi) { $query_string = $haveget?$section_text['GET']:''; - + if (!array_key_exists('GATEWAY_INTERFACE', $env)) $env['GATEWAY_INTERFACE']='CGI/1.1'; if (!array_key_exists('SERVER_SOFTWARE', $env)) @@ -1327,7 +1327,7 @@ function run_test($file) $env['SCRIPT_NAME']=''; if (!array_key_exists('SCRIPT_FILENAME', $env)) $env['SCRIPT_FILENAME']=''; - + if (array_key_exists('POST', $section_text) && (!$haveget || !empty($section_text['POST']))) { $post = $section_text['POST']; $content_length = strlen($post); @@ -1346,14 +1346,14 @@ function run_test($file) $env['CONTENT_LENGTH']=''; } if ($this->conf['TEST_PHP_DETAILED'] > 1) - $this->writemsg("\nCONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . - "\nCONTENT_TYPE = " . $env['CONTENT_TYPE'] . - "\nPATH_TRANSLATED = " . $env['PATH_TRANSLATED'] . - "\nPATH_INFO = " . $env['PATH_INFO'] . - "\nQUERY_STRING = " . $env['QUERY_STRING'] . - "\nREDIRECT_STATUS = " . $env['REDIRECT_STATUS'] . - "\nREQUEST_METHOD = " . $env['REQUEST_METHOD'] . - "\nSCRIPT_NAME = " . $env['SCRIPT_NAME'] . + $this->writemsg("\nCONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . + "\nCONTENT_TYPE = " . $env['CONTENT_TYPE'] . + "\nPATH_TRANSLATED = " . $env['PATH_TRANSLATED'] . + "\nPATH_INFO = " . $env['PATH_INFO'] . + "\nQUERY_STRING = " . $env['QUERY_STRING'] . + "\nREDIRECT_STATUS = " . $env['REDIRECT_STATUS'] . + "\nREQUEST_METHOD = " . $env['REQUEST_METHOD'] . + "\nSCRIPT_NAME = " . $env['SCRIPT_NAME'] . "\nSCRIPT_FILENAME = " . $env['SCRIPT_FILENAME'] . "\n"); /* not cgi spec to put query string on command line, but used by a couple tests to catch a security hole @@ -1362,7 +1362,7 @@ function run_test($file) $args = $env['QUERY_STRING']; $args = "$ini_overwrites $tmp_file \"$args\" 2>&1"; } else { - $args = $section_text['ARGS'] ? $section_text['ARGS'] : ''; + $args = $section_text['ARGS'] ?: ''; $args = "$ini_overwrites $tmp_file $args 2>&1"; } @@ -1390,14 +1390,14 @@ function run_test($file) } } } - + if ($this->conf['TEST_PHP_DETAILED'] > 2) { echo "HEADERS: "; print_r($headers); echo "OUTPUT: \n$out\n"; - + } - + // Does the output match what is expected? $output = trim($out); $output = preg_replace('/\r\n/',"\n",$output); @@ -1431,10 +1431,10 @@ function run_test($file) $start = $end = $length; } // quote a non re portion of the string - $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), '/'); + $temp .= preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), '/'); // add the re unquoted. if ($end > $start) { - $temp = $temp . '(' . substr($wanted_re, $start+2, ($end - $start-2)). ')'; + $temp = $temp . '(' . substr($wanted_re, $start+2, $end - $start-2). ')'; } $startOffset = $end + 2; } @@ -1473,7 +1473,7 @@ function run_test($file) $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 var_dump($wanted_re); @@ -1482,7 +1482,7 @@ function run_test($file) */ $failed = !preg_match("/^$wanted_re\$/s", $output); } - + $skipexpect = false; if (!$failed && $this->conf['TEST_WEB'] && isset($section_text['EXPECTHEADERS'])) { $want = array(); @@ -1502,7 +1502,7 @@ function run_test($file) $failed = TRUE; } } - + // different servers may do different things on non-200 results // for instance, IIS will deliver it's own error pages, so we // cannot expect to match up the EXPECT section. We may however, @@ -1510,50 +1510,50 @@ function run_test($file) // need to change later. $skipexpect = isset($headers['Status']) && $headers['Status'] != 200; } - + if (!$failed && !$skipexpect && isset($section_text['EXPECT'])) { $wanted = $section_text['EXPECT']; $wanted = preg_replace('/\r\n/',"\n",$wanted); $failed = (0 != strcmp($output,$wanted)); } - + if (!$failed) { @unlink($tmp_file); $this->showstatus($tested, 'PASSED'); return 'PASSED'; } - + // Test failed so we need to report details. $this->showstatus($tested, 'FAILED'); - + $this->failed_tests[] = array( 'name' => $file, 'test_name' => $tested, 'output' => preg_replace('/\.phpt$/','.log', $file), 'diff' => preg_replace('/\.phpt$/','.diff', $file) ); - + if ($this->conf['TEST_PHP_DETAILED']) $this->writemsg(generate_diff($wanted,$output)."\n"); - + // write .exp if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'E') !== FALSE) { $logname = preg_replace('/\.phpt$/','.exp',$file); file_put_contents($logname,$wanted); } - + // write .out if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'O') !== FALSE) { $logname = preg_replace('/\.phpt$/','.out',$file); file_put_contents($logname,$output); } - + // write .diff if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'D') !== FALSE) { $logname = preg_replace('/\.phpt$/','.diff',$file); file_put_contents($logname,generate_diff($wanted,$output)); } - + // write .log if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'L') !== FALSE) { $logname = preg_replace('/\.phpt$/','.log',$file); @@ -1572,7 +1572,7 @@ function run_test($file) // // Write an error in a format recognizable to Emacs or MSVC. // - function error_report($testname,$logname,$tested) + function error_report($testname,$logname,$tested) { $testname = realpath($testname); $logname = realpath($logname);