diff options
author | Dusta <dusta@users.noreply.github.com> | 2018-06-27 18:14:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-27 18:14:03 +0200 |
commit | 1deda9326e2d83563662e43f48cce7d39375473a (patch) | |
tree | 4e011caea460767b0fa0500ffbb7347639c3d8d3 /run-tests.php | |
parent | 3f241f3caa3e66e4d0e61d27701c3ef3b7deea2b (diff) | |
download | php-git-1deda9326e2d83563662e43f48cce7d39375473a.tar.gz |
Update Coding style
Diffstat (limited to 'run-tests.php')
-rw-r--r-- | run-tests.php | 524 |
1 files changed, 277 insertions, 247 deletions
diff --git a/run-tests.php b/run-tests.php index e7f908c2e8..4ec7cf5200 100644 --- a/run-tests.php +++ b/run-tests.php @@ -52,7 +52,7 @@ if (!extension_loaded('pcre')) { +-----------------------------------------------------------+ NO_PCRE_ERROR; -exit(1); + exit(1); } if (!function_exists('proc_open')) { @@ -65,7 +65,7 @@ if (!function_exists('proc_open')) { +-----------------------------------------------------------+ NO_PROC_OPEN_ERROR; -exit(1); + exit(1); } // If timezone is not set, use UTC. @@ -84,7 +84,7 @@ set_time_limit(0); ini_set('pcre.backtrack_limit', PHP_INT_MAX); // delete as much output buffers as possible -while(@ob_end_clean()); +while (@ob_end_clean()); if (ob_get_level()) echo "Not all buffers were deleted.\n"; error_reporting(E_ALL); @@ -105,15 +105,15 @@ if (empty($environment['TEMP'])) { // (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) { + } 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; + 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"); + $environment["SystemRoot"] = getenv("SystemRoot"); } // Don't ever guess at the PHP executable location. @@ -127,7 +127,7 @@ $phpdbg = null; if (getenv('TEST_PHP_EXECUTABLE')) { $php = getenv('TEST_PHP_EXECUTABLE'); - if ($php=='auto') { + if ($php == 'auto') { $php = TEST_PHP_SRCDIR . '/sapi/cli/php'; putenv("TEST_PHP_EXECUTABLE=$php"); @@ -147,7 +147,7 @@ if (getenv('TEST_PHP_EXECUTABLE')) { if (getenv('TEST_PHP_CGI_EXECUTABLE')) { $php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE'); - if ($php_cgi=='auto') { + if ($php_cgi == 'auto') { $php_cgi = TEST_PHP_SRCDIR . '/sapi/cgi/php-cgi'; putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi"); } @@ -175,7 +175,7 @@ if (!getenv('TEST_PHPDBG_EXECUTABLE')) { if (getenv('TEST_PHPDBG_EXECUTABLE')) { $phpdbg = getenv('TEST_PHPDBG_EXECUTABLE'); - if ($phpdbg=='auto') { + if ($phpdbg == 'auto') { $phpdbg = TEST_PHP_SRCDIR . '/sapi/phpdbg/phpdbg'; putenv("TEST_PHPDBG_EXECUTABLE=$phpdbg"); } @@ -189,11 +189,11 @@ if (!function_exists("hrtime")) { $t = microtime(true); if ($as_num) { - return $t*1000000000; + return $t * 1000000000; } $s = floor($t); - return array(0 => $s, 1 => ($t - $s)*1000000000); + return array(0 => $s, 1 => ($t - $s) * 1000000000); } } @@ -233,39 +233,39 @@ if (getenv('SHOW_ONLY_GROUPS')) { // Check whether user test dirs are requested. if (getenv('TEST_PHP_USER')) { - $user_tests = explode (',', getenv('TEST_PHP_USER')); + $user_tests = explode(',', getenv('TEST_PHP_USER')); } else { $user_tests = array(); } $exts_to_test = array(); $ini_overwrites = array( - 'output_handler=', - 'open_basedir=', - 'disable_functions=', - 'output_buffering=Off', - 'error_reporting=' . (E_ALL | E_STRICT), - 'display_errors=1', - 'display_startup_errors=1', - 'log_errors=0', - 'html_errors=0', - 'track_errors=0', - 'report_memleaks=1', - 'report_zend_debug=0', - 'docref_root=', - 'docref_ext=.html', - 'error_prepend_string=', - 'error_append_string=', - 'auto_prepend_file=', - 'auto_append_file=', - 'ignore_repeated_errors=0', - 'precision=14', - 'memory_limit=128M', - 'log_errors_max_len=0', - 'opcache.fast_shutdown=0', - 'opcache.file_update_protection=0', - 'zend.assertions=1', - ); + 'output_handler=', + 'open_basedir=', + 'disable_functions=', + 'output_buffering=Off', + 'error_reporting=' . (E_ALL | E_STRICT), + 'display_errors=1', + 'display_startup_errors=1', + 'log_errors=0', + 'html_errors=0', + 'track_errors=0', + 'report_memleaks=1', + 'report_zend_debug=0', + 'docref_root=', + 'docref_ext=.html', + 'error_prepend_string=', + 'error_append_string=', + 'auto_prepend_file=', + 'auto_append_file=', + 'ignore_repeated_errors=0', + 'precision=14', + 'memory_limit=128M', + 'log_errors_max_len=0', + 'opcache.fast_shutdown=0', + 'opcache.file_update_protection=0', + 'zend.assertions=1', +); $no_file_cache = '-d opcache.file_cache= -d opcache.file_cache_only=0'; @@ -313,7 +313,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" // load list of enabled extensions save_text($info_file, '<?php echo str_replace("Zend OPcache", "opcache", implode(",", get_loaded_extensions())); ?>'); - $exts_to_test = explode(',',`$php $pass_options $info_params $no_file_cache "$info_file"`); + $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( 'session' => array('session.auto_start=0'), @@ -323,7 +323,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" 'mbstring' => array('mbstring.func_overload=0'), ); - foreach($info_params_ex as $ext => $ini_overwrites_ex) { + foreach ($info_params_ex as $ext => $ini_overwrites_ex) { if (in_array($ext, $exts_to_test)) { $ini_overwrites = array_merge($ini_overwrites, $ini_overwrites_ex); } @@ -338,7 +338,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" echo " ===================================================================== PHP : $php $php_info $php_cgi_info $phpdbg_info -CWD : ".TEST_PHP_SRCDIR." +CWD : " . TEST_PHP_SRCDIR . " Extra dirs : "; foreach ($user_tests as $test_dir) { echo "{$test_dir}\n "; @@ -352,12 +352,12 @@ VALGRIND : " . ($valgrind ? $valgrind->getHeader() : 'Not used') . " define('PHP_QA_EMAIL', 'qa-reports@lists.php.net'); define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php'); define('QA_REPORTS_PAGE', 'http://qa.php.net/reports'); -define('TRAVIS_CI' , (bool) getenv('TRAVIS')); +define('TRAVIS_CI', (bool)getenv('TRAVIS')); function save_or_mail_results() { global $sum_results, $just_save_results, $failed_test_summary, - $PHP_FAILED_TESTS, $php, $output_file; + $PHP_FAILED_TESTS, $php, $output_file; /* 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) { @@ -369,7 +369,7 @@ function save_or_mail_results() echo QA_REPORTS_PAGE . " and http://news.php.net/php.qa.reports\n"; echo "This gives us a better understanding of PHP's behavior.\n"; echo "If you don't want to send the report immediately you can choose\n"; - echo "option \"s\" to save it. You can then email it to ". PHP_QA_EMAIL . " later.\n"; + echo "option \"s\" to save it. You can then email it to " . PHP_QA_EMAIL . " later.\n"; echo "Do you want to send this report now? [Yns]: "; flush(); @@ -442,7 +442,7 @@ function save_or_mail_results() $flags = array('-v', '-V', '--version'); $cc_status = 0; - foreach($flags AS $flag) { + foreach ($flags as $flag) { system(getenv('CC') . " $flag >/dev/null 2>&1", $cc_status); if ($cc_status == 0) { $compiler = shell_exec(getenv('CC') . " $flag 2>&1"); @@ -457,7 +457,7 @@ function save_or_mail_results() $failed_tests_data .= "Bundled Libtool:\n$libtool\n"; $failed_tests_data .= "System Libtool:\n$sys_libtool\n"; $failed_tests_data .= "Compiler:\n$compiler\n"; - $failed_tests_data .= "Bison:\n". shell_exec('bison --version 2>/dev/null') . "\n"; + $failed_tests_data .= "Bison:\n" . shell_exec('bison --version 2>/dev/null') . "\n"; $failed_tests_data .= "Libraries:\n$ldd\n"; $failed_tests_data .= "\n"; @@ -492,8 +492,8 @@ $test_results = array(); $PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array(), 'SLOW' => array()); // If parameters given assume they represent selected tests to run. -$result_tests_file= false; -$failed_tests_file= false; +$result_tests_file = false; +$failed_tests_file = false; $pass_option_n = false; $pass_options = ''; @@ -514,10 +514,10 @@ $cfgtypes = array('show', 'keep'); $cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp', 'mem'); $cfg = array(); -foreach($cfgtypes as $type) { +foreach ($cfgtypes as $type) { $cfg[$type] = array(); - foreach($cfgfiles as $file) { + foreach ($cfgfiles as $file) { $cfg[$type][$file] = false; } } @@ -534,23 +534,23 @@ if (getenv('TEST_PHP_ARGS')) { if (isset($argc) && $argc > 1) { - for ($i=1; $i<$argc; $i++) { + for ($i = 1; $i < $argc; $i++) { $is_switch = false; - $switch = substr($argv[$i],1,1); - $repeat = substr($argv[$i],0,1) == '-'; + $switch = substr($argv[$i], 1, 1); + $repeat = substr($argv[$i], 0, 1) == '-'; while ($repeat) { if (!$is_switch) { - $switch = substr($argv[$i],1,1); + $switch = substr($argv[$i], 1, 1); } $is_switch = true; if ($repeat) { - foreach($cfgtypes as $type) { + foreach ($cfgtypes as $type) { if (strpos($switch, '--' . $type) === 0) { - foreach($cfgfiles as $file) { + foreach ($cfgfiles as $file) { if ($switch == '--' . $type . '-' . $file) { $cfg[$type][$file] = true; $is_switch = false; @@ -568,12 +568,12 @@ if (isset($argc) && $argc > 1) { $repeat = false; - switch($switch) { + switch ($switch) { case 'r': case 'l': $test_list = file($argv[++$i]); if ($test_list) { - foreach($test_list as $test) { + foreach ($test_list as $test) { $matches = array(); if (preg_match('/^#.*\[(.*)\]\:\s+(.*)$/', $test, $matches)) { $redir_tests[] = array($matches[1], $matches[2]); @@ -607,7 +607,7 @@ if (isset($argc) && $argc > 1) { break; //case 'h' case '--keep-all': - foreach($cfgfiles as $file) { + foreach ($cfgfiles as $file) { $cfg['keep'][$file] = true; } break; @@ -633,7 +633,7 @@ if (isset($argc) && $argc > 1) { $environment['TEST_PHP_EXECUTABLE'] = $php; break; case 'P': - if(constant('PHP_BINARY')) { + if (constant('PHP_BINARY')) { $php = PHP_BINARY; } else { break; @@ -653,7 +653,7 @@ if (isset($argc) && $argc > 1) { $environment['TEST_TIMEOUT'] = $argv[++$i]; break; case '--show-all': - foreach($cfgfiles as $file) { + foreach ($cfgfiles as $file) { $cfg['show'][$file] = true; } break; @@ -875,8 +875,7 @@ HELP; junit_save_xml(); if (getenv('REPORT_EXIT_STATUS') !== '0' && - getenv('REPORT_EXIT_STATUS') !== 'no' && - ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['LEAKED'])) { + getenv('REPORT_EXIT_STATUS') !== 'no' && ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['LEAKED'])) { exit(1); } @@ -896,7 +895,7 @@ sort($exts_to_test); $test_dirs = array(); $optionals = array('tests', 'ext', 'Zend', 'sapi'); -foreach($optionals as $dir) { +foreach ($optionals as $dir) { if (is_dir($dir)) { $test_dirs[] = $dir; } @@ -908,7 +907,7 @@ foreach ($exts_to_test as $key => $val) { } foreach ($test_dirs as $dir) { - find_files(TEST_PHP_SRCDIR."/{$dir}", $dir == 'ext'); + find_files(TEST_PHP_SRCDIR . "/{$dir}", $dir == 'ext'); } foreach ($user_tests as $dir) { @@ -965,8 +964,8 @@ function test_sort($a, $b) $a = test_name($a); $b = test_name($b); - $ta = strpos($a, TEST_PHP_SRCDIR."/tests") === 0 ? 1 + (strpos($a, TEST_PHP_SRCDIR."/tests/run-test") === 0 ? 1 : 0) : 0; - $tb = strpos($b, TEST_PHP_SRCDIR."/tests") === 0 ? 1 + (strpos($b, TEST_PHP_SRCDIR."/tests/run-test") === 0 ? 1 : 0) : 0; + $ta = strpos($a, TEST_PHP_SRCDIR . "/tests") === 0 ? 1 + (strpos($a, TEST_PHP_SRCDIR . "/tests/run-test") === 0 ? 1 : 0) : 0; + $tb = strpos($b, TEST_PHP_SRCDIR . "/tests") === 0 ? 1 + (strpos($b, TEST_PHP_SRCDIR . "/tests/run-test") === 0 ? 1 : 0) : 0; if ($ta == $tb) { return strcmp($a, $b); @@ -1014,8 +1013,7 @@ save_or_mail_results(); junit_save_xml(); if (getenv('REPORT_EXIT_STATUS') !== '0' && - getenv('REPORT_EXIT_STATUS') !== 'no' && - ($sum_results['FAILED'] || $sum_results['LEAKED'])) { + getenv('REPORT_EXIT_STATUS') !== 'no' && ($sum_results['FAILED'] || $sum_results['LEAKED'])) { exit(1); } exit(0); @@ -1030,7 +1028,7 @@ function mail_qa_team($data, $status = false) if (($proxy = getenv('http_proxy'))) { $proxy = parse_url($proxy); - $path = $url_bits['host'].$url_bits['path']; + $path = $url_bits['host'] . $url_bits['path']; $host = $proxy['host']; if (empty($proxy['port'])) { $proxy['port'] = 80; @@ -1053,7 +1051,7 @@ function mail_qa_team($data, $status = false) $php_version = urlencode(TESTED_PHP_VERSION); - echo "\nPosting to ". QA_SUBMISSION_PAGE . "\n"; + echo "\nPosting to " . QA_SUBMISSION_PAGE . "\n"; fwrite($fs, "POST " . $path . "?status=$status&version=$php_version HTTP/1.1\r\n"); fwrite($fs, "Host: " . $host . "\r\n"); fwrite($fs, "User-Agent: QA Browser 0.1\r\n"); @@ -1099,7 +1097,7 @@ $text function error_report($testname, $logname, $tested) { $testname = realpath($testname); - $logname = realpath($logname); + $logname = realpath($logname); switch (strtoupper(getenv('TEST_PHP_ERROR_STYLE'))) { case 'MSVC': @@ -1120,7 +1118,7 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS $data = ''; $bin_env = array(); - foreach((array)$env as $key => $value) { + foreach ((array)$env as $key => $value) { $bin_env[$key] = $value; } @@ -1198,7 +1196,7 @@ function run_all_tests($test_files, $env, $redir_tested = null) { global $test_results, $failed_tests_file, $result_tests_file, $php, $test_idx; - foreach($test_files as $name) { + foreach ($test_files as $name) { if (is_array($name)) { $index = "# $name[1]: $name[0]"; @@ -1310,7 +1308,7 @@ TEST $file // Match the beginning of a section. if (preg_match('/^--([_A-Z]+)--/', $line, $r)) { - $section = (string) $r[1]; + $section = (string)$r[1]; if (isset($section_text[$section]) && $section_text[$section]) { $bork_info = "duplicated $section section"; @@ -1366,7 +1364,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 (isset($section_text[$key])) { @@ -1394,12 +1392,12 @@ TEST $file if ($bork_info !== null) { show_result("BORK", $bork_info, $tested_file); - $PHP_FAILED_TESTS['BORKED'][] = array ( - 'name' => $file, - 'test_name' => '', - 'output' => '', - 'diff' => '', - 'info' => "$bork_info [$file]", + $PHP_FAILED_TESTS['BORKED'][] = array( + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$bork_info [$file]", ); junit_mark_test_as('BORK', $shortname, $tested_file, 0, $bork_info); @@ -1450,7 +1448,7 @@ TEST $file /* For phpdbg tests, check if phpdbg sapi is available and if it is, use it. */ if (array_key_exists('PHPDBG', $section_text)) { if (!isset($section_text['STDIN'])) { - $section_text['STDIN'] = $section_text['PHPDBG']."\n"; + $section_text['STDIN'] = $section_text['PHPDBG'] . "\n"; } if (isset($phpdbg)) { @@ -1478,28 +1476,28 @@ TEST $file $temp_dir = str_replace($temp_source, $temp_target, $temp_dir); } - $main_file_name = basename($file,'phpt'); + $main_file_name = basename($file, 'phpt'); - $diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff'; - $log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log'; - $exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp'; - $output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out'; + $diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff'; + $log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log'; + $exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp'; + $output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out'; $memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem'; - $sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh'; - $temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php'; - $test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php'; - $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php'; - $test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php'; - $temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; - $test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; - $tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.'); + $sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh'; + $temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php'; + $test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php'; + $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php'; + $test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php'; + $temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; + $test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; + $tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.'); $tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't'; if ($temp_source && $temp_target) { - $temp_skipif .= 's'; - $temp_file .= 's'; - $temp_clean .= 's'; - $copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps'; + $temp_skipif .= 's'; + $temp_file .= 's'; + $temp_clean .= 's'; + $copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps'; if (!is_dir(dirname($copy_file))) { mkdir(dirname($copy_file), 0777, true) or error("Cannot create output directory - " . dirname($copy_file)); @@ -1512,14 +1510,15 @@ TEST $file $temp_filenames = array( 'file' => $copy_file, 'diff' => $diff_filename, - 'log' => $log_filename, - 'exp' => $exp_filename, - 'out' => $output_filename, - 'mem' => $memcheck_filename, - 'sh' => $sh_filename, - 'php' => $temp_file, + 'log' => $log_filename, + 'exp' => $exp_filename, + 'out' => $output_filename, + 'mem' => $memcheck_filename, + 'sh' => $sh_filename, + 'php' => $temp_file, 'skip' => $temp_skipif, - 'clean'=> $temp_clean); + 'clean' => $temp_clean + ); } if (is_array($IN_REDIRECT)) { @@ -1544,17 +1543,17 @@ TEST $file // Reset environment from any previous test. $env['REDIRECT_STATUS'] = ''; - $env['QUERY_STRING'] = ''; + $env['QUERY_STRING'] = ''; $env['PATH_TRANSLATED'] = ''; $env['SCRIPT_FILENAME'] = ''; - $env['REQUEST_METHOD'] = ''; - $env['CONTENT_TYPE'] = ''; - $env['CONTENT_LENGTH'] = ''; - $env['TZ'] = ''; + $env['REQUEST_METHOD'] = ''; + $env['CONTENT_TYPE'] = ''; + $env['CONTENT_LENGTH'] = ''; + $env['TZ'] = ''; if (!empty($section_text['ENV'])) { - foreach(explode("\n", trim($section_text['ENV'])) as $e) { + foreach (explode("\n", trim($section_text['ENV'])) as $e) { $e = explode('=', trim($e), 2); if (!empty($e[0]) && isset($e[1])) { @@ -1571,7 +1570,7 @@ TEST $file $ext_params = array(); settings2array($ini_overwrites, $ext_params); settings2params($ext_params); - $ext_dir=`$php $pass_options $ext_params -d display_errors=0 -r "echo ini_get('extension_dir');"`; + $ext_dir = `$php $pass_options $ext_params -d display_errors=0 -r "echo ini_get('extension_dir');"`; $extensions = preg_split("/[\n\r]+/", trim($section_text['EXTENSIONS'])); $loaded = explode(",", `$php $pass_options $ext_params -d display_errors=0 -r "echo implode(',', get_loaded_extensions());"`); $ext_prefix = substr(PHP_OS, 0, 3) === "WIN" ? "php_" : ""; @@ -1596,7 +1595,7 @@ TEST $file if (strpos($section_text['INI'], '{PWD}') !== false) { $section_text['INI'] = str_replace('{PWD}', dirname($file), $section_text['INI']); } - settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings); + settings2array(preg_split("/[\n\r]+/", $section_text['INI']), $ini_settings); } settings2params($ini_settings); @@ -1611,7 +1610,7 @@ TEST $file show_file_block('skip', $section_text['SKIPIF']); save_text($test_skipif, $section_text['SKIPIF'], $temp_skipif); $extra = substr(PHP_OS, 0, 3) !== "WIN" ? - "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": ""; + "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; if ($valgrind) { $env['USE_ZEND_ALLOC'] = '0'; @@ -1669,9 +1668,8 @@ TEST $file } if (!extension_loaded("zlib") - && ( array_key_exists("GZIP_POST", $section_text) - || array_key_exists("DEFLATE_POST", $section_text)) - ) { + && (array_key_exists("GZIP_POST", $section_text) + || array_key_exists("DEFLATE_POST", $section_text))) { $message = "ext/zlib required"; show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames); junit_mark_test_as('SKIP', $shortname, $tested, null, $message); @@ -1694,7 +1692,7 @@ TEST $file $GLOBALS['test_files'] = $test_files; find_files($IN_REDIRECT['TESTS']); - foreach($GLOBALS['test_files'] as $f) { + foreach ($GLOBALS['test_files'] as $f) { $test_files[] = array($f, $file); } } @@ -1722,12 +1720,12 @@ TEST $file $bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory."; show_result("BORK", $bork_info, '', $temp_filenames); - $PHP_FAILED_TESTS['BORKED'][] = array ( - 'name' => $file, - 'test_name' => '', - 'output' => '', - 'diff' => '', - 'info' => "$bork_info [$file]", + $PHP_FAILED_TESTS['BORKED'][] = array( + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$bork_info [$file]", ); } } @@ -1740,12 +1738,12 @@ TEST $file $bork_info = "Redirected test did not contain redirection info"; show_result("BORK", $bork_info, '', $temp_filenames); - $PHP_FAILED_TESTS['BORKED'][] = array ( - 'name' => $file, - 'test_name' => '', - 'output' => '', - 'diff' => '', - 'info' => "$bork_info [$file]", + $PHP_FAILED_TESTS['BORKED'][] = array( + 'name' => $file, + 'test_name' => '', + 'output' => '', + 'diff' => '', + 'info' => "$bork_info [$file]", ); junit_mark_test_as('BORK', $shortname, $tested, null, $bork_info); @@ -1769,7 +1767,7 @@ TEST $file $env['REDIRECT_STATUS'] = '1'; if (empty($env['QUERY_STRING'])) { - $env['QUERY_STRING'] = $query_string; + $env['QUERY_STRING'] = $query_string; } if (empty($env['PATH_TRANSLATED'])) { $env['PATH_TRANSLATED'] = $test_file; @@ -1862,7 +1860,7 @@ TEST $file $env['REQUEST_METHOD'] = 'POST'; if (empty($env['CONTENT_TYPE'])) { - $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; + $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; } if (empty($env['CONTENT_LENGTH'])) { @@ -1881,7 +1879,7 @@ TEST $file $content_length = strlen($post); $env['REQUEST_METHOD'] = 'POST'; - $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; + $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\""; @@ -1894,7 +1892,7 @@ TEST $file $content_length = strlen($post); $env['REQUEST_METHOD'] = 'POST'; - $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; + $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\""; @@ -1902,7 +1900,7 @@ TEST $file } else { $env['REQUEST_METHOD'] = 'GET'; - $env['CONTENT_TYPE'] = ''; + $env['CONTENT_TYPE'] = ''; $env['CONTENT_LENGTH'] = ''; $cmd = "$php $pass_options $ini_settings -f \"$test_file\" $args$cmdRedirect"; @@ -1932,20 +1930,20 @@ COMMAND $cmd junit_start_timer($shortname); $hrtime = hrtime(); - $startTime = $hrtime[0]*1000000000 + $hrtime[1]; + $startTime = $hrtime[0] * 1000000000 + $hrtime[1]; $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null, $captureStdIn, $captureStdOut, $captureStdErr); junit_finish_timer($shortname); $hrtime = hrtime(); - $time = $hrtime[0]*1000000000 + $hrtime[1] - $startTime; + $time = $hrtime[0] * 1000000000 + $hrtime[1] - $startTime; if ($time >= $slow_min_ms * 1000000) { $PHP_FAILED_TESTS['SLOW'][] = array( - 'name' => $file, + 'name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [$tested_file]", - 'output' => '', - 'diff' => '', - 'info' => $time / 1000000000, + 'output' => '', + 'diff' => '', + 'info' => $time / 1000000000, ); } @@ -1960,7 +1958,7 @@ COMMAND $cmd settings2array($ini_overwrites, $clean_params); settings2params($clean_params); $extra = substr(PHP_OS, 0, 3) !== "WIN" ? - "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": ""; + "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : ""; system_with_timeout("$extra $php $pass_options -q $clean_params $no_file_cache \"$test_clean\"", $env); } @@ -2008,7 +2006,7 @@ COMMAND $cmd $wanted_headers = array(); $lines = preg_split("/[\n\r]+/", $section_text['EXPECTHEADERS']); - foreach($lines as $line) { + foreach ($lines as $line) { if (strpos($line, ':') !== false) { $line = explode(':', $line, 2); $want[trim($line[0])] = trim($line[1]); @@ -2018,7 +2016,7 @@ COMMAND $cmd $output_headers = array(); - foreach($want as $k => $v) { + foreach ($want as $k => $v) { if (isset($headers[$k])) { $output_headers[] = $k . ': ' . $headers[$k]; @@ -2055,11 +2053,11 @@ COMMAND $cmd $r = "%r"; $startOffset = 0; $length = strlen($wanted_re); - while($startOffset < $length) { + while ($startOffset < $length) { $start = strpos($wanted_re, $r, $startOffset); if ($start !== false) { // we have found a start tag - $end = strpos($wanted_re, $r, $start+2); + $end = strpos($wanted_re, $r, $start + 2); if ($end === false) { // unbalanced tag, ignore it. $end = $start = $length; @@ -2069,10 +2067,10 @@ COMMAND $cmd $start = $end = $length; } // quote a non re portion of the string - $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 .= '(' . substr($wanted_re, $start+2, $end - $start-2). ')'; + $temp .= '(' . substr($wanted_re, $start + 2, $end - $start - 2) . ')'; } $startOffset = $end + 2; } @@ -2096,7 +2094,7 @@ COMMAND $cmd var_dump($wanted_re); print(str_repeat('=', 80) . "\n"); var_dump($output); -*/ + */ if (preg_match("/^$wanted_re\$/s", $output)) { $passed = true; if (!$cfg['keep']['php']) { @@ -2104,10 +2102,10 @@ COMMAND $cmd } if (!$leaked && !$failed_headers) { - if (isset($section_text['XFAIL'] )) { + if (isset($section_text['XFAIL'])) { $warn = true; $info = " (warn: XFAIL section but test passes)"; - }else { + } else { show_result("PASS", $tested, $tested_file, '', $temp_filenames); junit_mark_test_as('PASS', $shortname, $tested); return 'PASSED'; @@ -2118,7 +2116,7 @@ COMMAND $cmd } else { $wanted = trim($section_text['EXPECT']); - $wanted = preg_replace('/\r\n/',"\n", $wanted); + $wanted = preg_replace('/\r\n/', "\n", $wanted); show_file_block('exp', $wanted); // compare and leave on success @@ -2130,10 +2128,10 @@ COMMAND $cmd } if (!$leaked && !$failed_headers) { - if (isset($section_text['XFAIL'] )) { + if (isset($section_text['XFAIL'])) { $warn = true; $info = " (warn: XFAIL section but test passes)"; - }else { + } else { show_result("PASS", $tested, $tested_file, '', $temp_filenames); junit_mark_test_as('PASS', $shortname, $tested); return 'PASSED'; @@ -2215,7 +2213,7 @@ $output error_report($file, $log_filename, $tested); } } - + if ($valgrind && $leaked && $cfg["show"]["mem"]) { show_file_block('mem', file_get_contents($memcheck_filename)); } @@ -2223,12 +2221,12 @@ $output show_result(implode('&', $restype), $tested, $tested_file, $info, $temp_filenames); foreach ($restype as $type) { - $PHP_FAILED_TESTS[$type.'ED'][] = array ( - 'name' => $file, + $PHP_FAILED_TESTS[$type . 'ED'][] = array( + 'name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [$tested_file]", - 'output' => $output_filename, - 'diff' => $diff_filename, - 'info' => $info, + 'output' => $output_filename, + 'diff' => $diff_filename, + 'info' => $info, ); } @@ -2242,7 +2240,7 @@ $output function comp_line($l1, $l2, $is_reg) { if ($is_reg) { - return preg_match('/^'. $l1 . '$/s', $l2); + return preg_match('/^' . $l1 . '$/s', $l2); } else { return !strcmp($l1, $l2); } @@ -2292,8 +2290,10 @@ 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; + $cnt1 = @count($ar1); + $idx2 = 0; + $cnt2 = @count($ar2); $diff = array(); $old1 = array(); $old2 = array(); @@ -2306,22 +2306,26 @@ function generate_array_diff($ar1, $ar2, $is_reg, $w) continue; } else { - $c1 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1+1, $idx2, $cnt1, $cnt2, 10); - $c2 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2+1, $cnt1, $cnt2, 10); + $c1 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1 + 1, $idx2, $cnt1, $cnt2, 10); + $c2 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2 + 1, $cnt1, $cnt2, 10); if ($c1 > $c2) { - $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++]; + $old1[$idx1] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++]; } else if ($c2 > 0) { - $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++]; + $old2[$idx2] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++]; } else { - $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++]; - $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++]; + $old1[$idx1] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++]; + $old2[$idx2] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++]; } } } - reset($old1); $k1 = key($old1); $l1 = -2; - reset($old2); $k2 = key($old2); $l2 = -2; + reset($old1); + $k1 = key($old1); + $l1 = -2; + reset($old2); + $k2 = key($old2); + $l2 = -2; while ($k1 !== null || $k2 !== null) { @@ -2373,7 +2377,7 @@ function error($message) function settings2array($settings, &$ini_settings) { - foreach($settings as $setting) { + foreach ($settings as $setting) { if (strpos($setting, '=') !== false) { $setting = explode("=", $setting, 2); @@ -2432,12 +2436,12 @@ function compute_summary() $n_total = count($test_results); $n_total += $ignored_by_ext; $sum_results = array( - 'PASSED' => 0, - 'WARNED' => 0, + 'PASSED' => 0, + 'WARNED' => 0, 'SKIPPED' => 0, - 'FAILED' => 0, - 'BORKED' => 0, - 'LEAKED' => 0, + 'FAILED' => 0, + 'BORKED' => 0, + 'LEAKED' => 0, 'XFAILED' => 0 ); @@ -2514,7 +2518,7 @@ 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) { + usort($PHP_FAILED_TESTS['SLOW'], function ($a, $b) { return $a['info'] < $b['info'] ? 1 : -1; }); @@ -2526,7 +2530,7 @@ 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"; + $failed_test_summary .= "=====================================================================\n"; } if (count($PHP_FAILED_TESTS['XFAILED'])) { @@ -2538,7 +2542,7 @@ EXPECTED FAILED TEST SUMMARY foreach ($PHP_FAILED_TESTS['XFAILED'] as $failed_test_data) { $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n"; } - $failed_test_summary .= "=====================================================================\n"; + $failed_test_summary .= "=====================================================================\n"; } if (count($PHP_FAILED_TESTS['BORKED'])) { @@ -2551,7 +2555,7 @@ BORKED TEST SUMMARY $failed_test_summary .= $failed_test_data['info'] . "\n"; } - $failed_test_summary .= "=====================================================================\n"; + $failed_test_summary .= "=====================================================================\n"; } if (count($PHP_FAILED_TESTS['FAILED'])) { @@ -2563,7 +2567,7 @@ FAILED TEST SUMMARY foreach ($PHP_FAILED_TESTS['FAILED'] as $failed_test_data) { $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n"; } - $failed_test_summary .= "=====================================================================\n"; + $failed_test_summary .= "=====================================================================\n"; } if (count($PHP_FAILED_TESTS['WARNED'])) { $failed_test_summary .= ' @@ -2575,7 +2579,7 @@ WARNED TEST SUMMARY $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n"; } - $failed_test_summary .= "=====================================================================\n"; + $failed_test_summary .= "=====================================================================\n"; } if (count($PHP_FAILED_TESTS['LEAKED'])) { @@ -2588,7 +2592,7 @@ LEAKED TEST SUMMARY $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n"; } - $failed_test_summary .= "=====================================================================\n"; + $failed_test_summary .= "=====================================================================\n"; } if ($failed_test_summary && !getenv('NO_PHPTEST_SUMMARY')) { @@ -2646,10 +2650,10 @@ function show_redirect_start($tests, $tested, $tested_file) } if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) { - echo "REDIRECT $tests ($tested [$tested_file]) begin\n"; + echo "REDIRECT $tests ($tested [$tested_file]) begin\n"; } else { // Write over the last line to avoid random trailing chars on next echo - echo str_repeat(" ", $line_length), "\r"; + echo str_repeat(" ", $line_length), "\r"; } } @@ -2662,10 +2666,10 @@ function show_redirect_ends($tests, $tested, $tested_file) } if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) { - echo "REDIRECT $tests ($tested [$tested_file]) done\n"; + echo "REDIRECT $tests ($tested [$tested_file]) done\n"; } else { // Write over the last line to avoid random trailing chars on next echo - echo str_repeat(" ", $line_length), "\r"; + echo str_repeat(" ", $line_length), "\r"; } } @@ -2725,51 +2729,59 @@ function show_result($result, $tested, $tested_file, $extra = '', $temp_filename $mem = " "; } - fwrite($html_file, + fwrite( + $html_file, "<tr>" . - "<td>$result</td>" . - "<td>$tested</td>" . - "<td>$extra</td>" . - "<td>$diff</td>" . - "<td>$mem</td>" . - "</tr>\n"); + "<td>$result</td>" . + "<td>$tested</td>" . + "<td>$extra</td>" . + "<td>$diff</td>" . + "<td>$mem</td>" . + "</tr>\n" + ); } } -function junit_init() { +function junit_init() +{ // Check whether a junit log is wanted. $JUNIT = getenv('TEST_PHP_JUNIT'); if (empty($JUNIT)) { - $JUNIT = FALSE; + $JUNIT = false; } elseif (!$fp = fopen($JUNIT, 'w')) { error("Failed to open $JUNIT for writing."); } else { $JUNIT = array( - 'fp' => $fp, - 'name' => 'PHP', - 'test_total' => 0, - 'test_pass' => 0, - 'test_fail' => 0, - 'test_error' => 0, - 'test_skip' => 0, - 'test_warn' => 0, - 'execution_time'=> 0, - 'suites' => array(), - 'files' => array() + 'fp' => $fp, + 'name' => 'PHP', + 'test_total' => 0, + 'test_pass' => 0, + 'test_fail' => 0, + 'test_error' => 0, + 'test_skip' => 0, + 'test_warn' => 0, + 'execution_time' => 0, + 'suites' => array(), + 'files' => array() ); } $GLOBALS['JUNIT'] = $JUNIT; } -function junit_save_xml() { +function junit_save_xml() +{ global $JUNIT; if (!junit_enabled()) return; - $xml = '<' . '?' . 'xml version="1.0" encoding="UTF-8"' . '?' . '>'. PHP_EOL; - $xml .= sprintf( + $xml = '<' . '?' . 'xml version="1.0" encoding="UTF-8"' . '?' . '>' . PHP_EOL; + $xml .= sprintf( '<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL, - $JUNIT['name'], $JUNIT['test_total'], $JUNIT['test_fail'], $JUNIT['test_error'], $JUNIT['test_skip'], + $JUNIT['name'], + $JUNIT['test_total'], + $JUNIT['test_fail'], + $JUNIT['test_error'], + $JUNIT['test_skip'], $JUNIT['execution_time'] ); $xml .= junit_get_suite_xml(); @@ -2777,7 +2789,8 @@ function junit_save_xml() { fwrite($JUNIT['fp'], $xml); } -function junit_get_suite_xml($suite_name = '') { +function junit_get_suite_xml($suite_name = '') +{ global $JUNIT; $result = ""; @@ -2785,12 +2798,16 @@ function junit_get_suite_xml($suite_name = '') { foreach ($JUNIT['suites'] as $suite_name => $suite) { $result .= sprintf( '<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s">' . PHP_EOL, - $suite['name'], $suite['test_total'], $suite['test_fail'], $suite['test_error'], $suite['test_skip'], + $suite['name'], + $suite['test_total'], + $suite['test_fail'], + $suite['test_error'], + $suite['test_skip'], $suite['execution_time'] ); if (!empty($suite_name)) { - foreach($suite['files'] as $file) { + foreach ($suite['files'] as $file) { $result .= $JUNIT['files'][$file]['xml']; } } @@ -2801,7 +2818,8 @@ function junit_get_suite_xml($suite_name = '') { return $result; } -function junit_enabled() { +function junit_enabled() +{ global $JUNIT; return !empty($JUNIT); } @@ -2815,7 +2833,8 @@ function junit_enabled() { * @param string $details * @return void */ -function junit_mark_test_as($type, $file_name, $test_name, $time = null, $message = '', $details = '') { +function junit_mark_test_as($type, $file_name, $test_name, $time = null, $message = '', $details = '') +{ global $JUNIT; if (!junit_enabled()) return; @@ -2832,8 +2851,8 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag }, $escaped_details); $escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8'); - $escaped_test_name = htmlspecialchars($test_name, ENT_QUOTES); - $JUNIT['files'][$file_name]['xml'] = "<testcase classname='" . $suite . "." . basename($file_name) . "' name='$escaped_test_name' time='$time'>\n"; + $escaped_test_name = htmlspecialchars($test_name, ENT_QUOTES); + $JUNIT['files'][$file_name]['xml'] = "<testcase classname='" . $suite . "." . basename($file_name) . "' name='$escaped_test_name' time='$time'>\n"; if (is_array($type)) { $output_type = $type[0] . 'ED'; @@ -2866,14 +2885,16 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag } -function junit_suite_record($suite, $param, $value = 1) { +function junit_suite_record($suite, $param, $value = 1) +{ global $JUNIT; $JUNIT[$param] += $value; $JUNIT['suites'][$suite][$param] += $value; } -function junit_get_timer($file_name) { +function junit_get_timer($file_name) +{ global $JUNIT; if (!junit_enabled()) return 0; @@ -2884,7 +2905,8 @@ function junit_get_timer($file_name) { return 0; } -function junit_start_timer($file_name) { +function junit_start_timer($file_name) +{ global $JUNIT; if (!junit_enabled()) return; @@ -2897,12 +2919,14 @@ function junit_start_timer($file_name) { } } -function junit_get_suitename_for($file_name) { +function junit_get_suitename_for($file_name) +{ return junit_path_to_classname(dirname($file_name)); } -function junit_path_to_classname($file_name) { - global $JUNIT; +function junit_path_to_classname($file_name) +{ + global $JUNIT; $ret = $JUNIT['name']; $_tmp = array(); @@ -2932,7 +2956,8 @@ function junit_path_to_classname($file_name) { return $JUNIT['name'] . '.' . str_replace(array(DIRECTORY_SEPARATOR, '-'), '.', $file_name); } -function junit_init_suite($suite_name) { +function junit_init_suite($suite_name) +{ global $JUNIT; if (!junit_enabled()) return; @@ -2941,19 +2966,20 @@ function junit_init_suite($suite_name) { } $JUNIT['suites'][$suite_name] = array( - 'name' => $suite_name, - 'test_total' => 0, - 'test_pass' => 0, - 'test_fail' => 0, - 'test_error' => 0, - 'test_skip' => 0, - 'suites' => array(), - 'files' => array(), - 'execution_time'=> 0, + 'name' => $suite_name, + 'test_total' => 0, + 'test_pass' => 0, + 'test_fail' => 0, + 'test_error' => 0, + 'test_skip' => 0, + 'suites' => array(), + 'files' => array(), + 'execution_time' => 0, ); } -function junit_finish_timer($file_name) { +function junit_finish_timer($file_name) +{ global $JUNIT; if (!junit_enabled()) return; @@ -2962,30 +2988,34 @@ function junit_finish_timer($file_name) { } if (!isset($JUNIT['files'][$file_name]['total'])) { - $JUNIT['files'][$file_name]['total'] = 0; - } + $JUNIT['files'][$file_name]['total'] = 0; + } $start = $JUNIT['files'][$file_name]['start']; $JUNIT['files'][$file_name]['total'] += microtime(true) - $start; unset($JUNIT['files'][$file_name]['start']); } -class RuntestsValgrind { +class RuntestsValgrind +{ protected $version = ''; protected $header = ''; protected $version_3_3_0 = false; protected $version_3_8_0 = false; - public function getVersion() { + public function getVersion() + { return $this->version; } - public function getHeader() { + public function getHeader() + { return $this->header; } - public function __construct(array $environment) { - $header = system_with_timeout('valgrind --version', $environment); + public function __construct(array $environment) + { + $header = system_with_timeout('valgrind --version', $environment); if (!$header) { error("Valgrind returned no version info, cannot proceed.\nPlease check if Valgrind is installed."); } @@ -3000,7 +3030,8 @@ class RuntestsValgrind { $this->version_3_8_0 = version_compare($version, '3.8.0', '>='); } - public function wrapCommand($cmd, $memcheck_filename, $check_all) { + public function wrapCommand($cmd, $memcheck_filename, $check_all) + { $vcmd = 'valgrind -q --tool=memcheck --trace-children=yes'; if ($check_all) { $vcmd .= ' --smc-check=all'; @@ -3025,4 +3056,3 @@ class RuntestsValgrind { * End: * vim: noet sw=4 ts=4 */ -?> |