GitHub PullRequestReviewCommentEvent at 2014-05-16 15:08:56
Repository: php-git
Actor: chobie
Payload: {"comment":{"url":"https://api.github.com/repos/libgit2/php-git/pulls/comments/12742879","id":12742879,"diff_hunk":"@@ -0,0 +1,2803 @@\n+#!/usr/bin/env php\n+<?php\n+\t/*\n+\t   +----------------------------------------------------------------------+\n+\t   | PHP Version 5                                                        |\n+\t   +----------------------------------------------------------------------+\n+\t   | Copyright (c) 1997-2010 The PHP Group                                |\n+\t   +----------------------------------------------------------------------+\n+\t   | This source file is subject to version 3.01 of the PHP license,      |\n+\t   | that is bundled with this package in the file LICENSE, and is        |\n+\t   | available through the world-wide-web at the following url:           |\n+\t   | http://www.php.net/license/3_01.txt                                  |\n+\t   | If you did not receive a copy of the PHP license and are unable to   |\n+\t   | obtain it through the world-wide-web, please send a note to          |\n+\t   | license@php.net so we can mail you a copy immediately.               |\n+\t   +----------------------------------------------------------------------+\n+\t   | Authors: Ilia Alshanetsky <iliaa@php.net>                            |\n+\t   |          Preston L. Bannister <pbannister@php.net>                   |\n+\t   |          Marcus Boerger <helly@php.net>                              |\n+\t   |          Derick Rethans <derick@php.net>                             |\n+\t   |          Sander Roobol <sander@php.net>                              |\n+\t   | (based on version by: Stig Bakken <ssb@php.net>)                     |\n+\t   | (based on the PHP 3 test framework by Rasmus Lerdorf)                |\n+\t   +----------------------------------------------------------------------+\n+\t */\n+\n+\t/* $Id: 305b48d9335b7fa38b96d023fd21bdbb2e6e52a9 $ */\n+\n+\t/* Sanity check to ensure that pcre extension needed by this script is available.\n+\t * In the event it is not, print a nice error message indicating that this script will\n+\t * not run without it.\n+\t */\n+\n+\tif (!extension_loaded('pcre')) {\n+\t\techo <<<NO_PCRE_ERROR\n+\n++-----------------------------------------------------------+\n+|                       ! ERROR !                           |\n+| The test-suite requires that you have pcre extension      |\n+| enabled. To enable this extension either compile your PHP |\n+| with --with-pcre-regex or if you've compiled pcre as a    |\n+| shared module load it via php.ini.                        |\n++-----------------------------------------------------------+\n+\n+NO_PCRE_ERROR;\n+\t\texit;\n+\t}\n+\n+\tif (!function_exists('proc_open')) {\n+\t\techo <<<NO_PROC_OPEN_ERROR\n+\n++-----------------------------------------------------------+\n+|                       ! ERROR !                           |\n+| The test-suite requires that proc_open() is available.    |\n+| Please check if you disabled it in php.ini.               |\n++-----------------------------------------------------------+\n+\n+NO_PROC_OPEN_ERROR;\n+\t\texit;\n+\t}\n+\n+\t// Version constants only available as of 5.2.8\n+\tif (!defined(\"PHP_VERSION_ID\")) {\n+\t\tlist($major, $minor, $bug) = explode(\".\", phpversion(), 3);\n+\t\t$bug = (int)$bug; // Many distros make up their own versions\n+\t\tif ($bug < 10) {\n+\t\t\t$bug = \"0$bug\";\n+\t\t}\n+\n+\t\tdefine(\"PHP_VERSION_ID\", \"{$major}0{$minor}$bug\");\n+\t\tdefine(\"PHP_MAJOR_VERSION\", $major);\n+\t}\n+\n+\t// __DIR__ is available from 5.3.0\n+\tif (PHP_VERSION_ID < 50300) {\n+\t\tdefine('__DIR__', realpath(dirname(__FILE__)));\n+\t\t// FILE_BINARY is available from 5.2.7\n+\t\tif (PHP_VERSION_ID < 50207) {\n+\t\t\tdefine('FILE_BINARY', 0);\n+\t\t}\n+\t}\n+\n+\t// If timezone is not set, use UTC.\n+\tif (ini_get('date.timezone') == '') {\n+\t\tdate_default_timezone_set('UTC');\n+\t}\n+\n+\t// store current directory\n+\t$CUR_DIR = getcwd();\n+\n+\t// change into the PHP source directory.\n+\n+\tif (getenv('TEST_PHP_SRCDIR')) {\n+\t\t@chdir(getenv('TEST_PHP_SRCDIR'));\n+\t}\n+\n+\t// Delete some security related environment variables\n+\tputenv('SSH_CLIENT=deleted');\n+\tputenv('SSH_AUTH_SOCK=deleted');\n+\tputenv('SSH_TTY=deleted');\n+\tputenv('SSH_CONNECTION=deleted');\n+\n+\t$cwd = getcwd();\n+\tset_time_limit(0);\n+\n+\tini_set('pcre.backtrack_limit', PHP_INT_MAX);\n+\n+\t$valgrind_version = 0;\n+\t$valgrind_header = '';\n+\n+\t// delete as much output buffers as possible\n+\twhile(@ob_end_clean());\n+\tif (ob_get_level()) echo \"Not all buffers were deleted.\\n\";\n+\n+\terror_reporting(E_ALL);\n+\tif (PHP_MAJOR_VERSION < 6) {\n+\t\tini_set('magic_quotes_runtime',0); // this would break tests by modifying EXPECT sections\n+\t\tif (ini_get('safe_mode')) {\n+\t\t\techo <<< SAFE_MODE_WARNING\n+\n++-----------------------------------------------------------+\n+|                       ! WARNING !                         |\n+| You are running the test-suite with \"safe_mode\" ENABLED ! |\n+|                                                           |\n+| Chances are high that no test will work at all,           |\n+| depending on how you configured \"safe_mode\" !             |\n++-----------------------------------------------------------+\n+\n+\n+SAFE_MODE_WARNING;\n+\t\t}\n+\t}\n+\n+\t$environment = isset($_ENV) ? $_ENV : array();\n+\tif ((substr(PHP_OS, 0, 3) == \"WIN\") && empty($environment[\"SystemRoot\"])) {\n+\t\t$environment[\"SystemRoot\"] = getenv(\"SystemRoot\");\n+\t}\n+\n+\t// Don't ever guess at the PHP executable location.\n+\t// Require the explicit specification.\n+\t// Otherwise we could end up testing the wrong file!\n+\n+\t$php = null;\n+\t$php_cgi = null;\n+\n+\tif (getenv('TEST_PHP_EXECUTABLE')) {\n+\t\t$php = getenv('TEST_PHP_EXECUTABLE');\n+\n+\t\tif ($php=='auto') {\n+\t\t\t$php = $cwd . '/sapi/cli/php';\n+\t\t\tputenv(\"TEST_PHP_EXECUTABLE=$php\");\n+\n+\t\t\tif (!getenv('TEST_PHP_CGI_EXECUTABLE')) {\n+\t\t\t\t$php_cgi = $cwd . '/sapi/cgi/php-cgi';\n+\n+\t\t\t\tif (file_exists($php_cgi)) {\n+\t\t\t\t\tputenv(\"TEST_PHP_CGI_EXECUTABLE=$php_cgi\");\n+\t\t\t\t} else {\n+\t\t\t\t\t$php_cgi = null;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\t$environment['TEST_PHP_EXECUTABLE'] = $php;\n+\t}\n+\n+\tif (getenv('TEST_PHP_CGI_EXECUTABLE')) {\n+\t\t$php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE');\n+\n+\t\tif ($php_cgi=='auto') {\n+\t\t\t$php_cgi = $cwd . '/sapi/cgi/php-cgi';\n+\t\t\tputenv(\"TEST_PHP_CGI_EXECUTABLE=$php_cgi\");\n+\t\t}\n+\n+\t\t$environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi;\n+\t}\n+\n+\tfunction verify_config()\n+\t{\n+\t\tglobal $php;\n+\n+\t\tif (empty($php) || !file_exists($php)) {\n+\t\t\terror('environment variable TEST_PHP_EXECUTABLE must be set to specify PHP executable!');\n+\t\t}\n+\n+\t\tif (function_exists('is_executable') && !is_executable($php)) {\n+\t\t\terror(\"invalid PHP executable specified by TEST_PHP_EXECUTABLE  = $php\");\n+\t\t}\n+\t}\n+\n+\tif (getenv('TEST_PHP_LOG_FORMAT')) {\n+\t\t$log_format = strtoupper(getenv('TEST_PHP_LOG_FORMAT'));\n+\t} else {\n+\t\t$log_format = 'LEODS';\n+\t}\n+\n+\t// Check whether a detailed log is wanted.\n+\tif (getenv('TEST_PHP_DETAILED')) {\n+\t\t$DETAILED = getenv('TEST_PHP_DETAILED');\n+\t} else {\n+\t\t$DETAILED = 0;\n+\t}\n+\n+\tjunit_init();\n+\n+\tif (getenv('SHOW_ONLY_GROUPS')) {\n+\t\t$SHOW_ONLY_GROUPS = explode(\",\", getenv('SHOW_ONLY_GROUPS'));\n+\t} else {\n+\t\t$SHOW_ONLY_GROUPS = array();\n+\t}\n+\n+\t// Check whether user test dirs are requested.\n+\tif (getenv('TEST_PHP_USER')) {\n+\t\t$user_tests = explode (',', getenv('TEST_PHP_USER'));\n+\t} else {\n+\t\t$user_tests = array();\n+\t}\n+\n+\t$exts_to_test = array();\n+\t$ini_overwrites = array(\n+\t\t'output_handler=',\n+\t\t'open_basedir=',\n+\t\t'safe_mode=0',\n+\t\t'disable_functions=',\n+\t\t'output_buffering=Off',\n+\t\t'error_reporting=' . (E_ALL | E_STRICT),\n+\t\t'display_errors=1',\n+\t\t'display_startup_errors=1',\n+\t\t'log_errors=0',\n+\t\t'html_errors=0',\n+\t\t'track_errors=1',\n+\t\t'report_memleaks=1',\n+\t\t'report_zend_debug=0',\n+\t\t'docref_root=',\n+\t\t'docref_ext=.html',\n+\t\t'error_prepend_string=',\n+\t\t'error_append_string=',\n+\t\t'auto_prepend_file=',\n+\t\t'auto_append_file=',\n+\t\t'magic_quotes_runtime=0',\n+\t\t'ignore_repeated_errors=0',\n+\t\t'precision=14',\n+\t\t'memory_limit=128M',\n+\t\t'opcache.fast_shutdown=0',\n+\t\t'opcache.file_update_protection=0',\n+\t);\n+\n+\tfunction write_information($show_html)\n+\t{\n+\t\tglobal $cwd, $php, $php_cgi, $php_info, $user_tests, $ini_overwrites, $pass_options, $exts_to_test, $leak_check, $valgrind_header;\n+\n+\t\t// Get info from php\n+\t\t$info_file = __DIR__ . '/run-test-info.php';\n+\t\t@unlink($info_file);\n+\t\t$php_info = '<?php echo \"\n+PHP_SAPI    : \" , PHP_SAPI , \"\n+PHP_VERSION : \" , phpversion() , \"\n+ZEND_VERSION: \" , zend_version() , \"\n+PHP_OS      : \" , PHP_OS , \" - \" , php_uname() , \"\n+INI actual  : \" , realpath(get_cfg_var(\"cfg_file_path\")) , \"\n+More .INIs  : \" , (function_exists(\\'php_ini_scanned_files\\') ? str_replace(\"\\n\",\"\", php_ini_scanned_files()) : \"** not determined **\"); ?>';\n+\t\tsave_text($info_file, $php_info);\n+\t\t$info_params = array();\n+\t\tsettings2array($ini_overwrites, $info_params);\n+\t\tsettings2params($info_params);\n+\t\t$php_info = `$php $pass_options $info_params \"$info_file\"`;\n+\t\tdefine('TESTED_PHP_VERSION', `$php -n -r \"echo PHP_VERSION;\"`);\n+\n+\t\tif ($php_cgi && $php != $php_cgi) {\n+\t\t\t$php_info_cgi = `$php_cgi $pass_options $info_params -q \"$info_file\"`;\n+\t\t\t$php_info_sep = \"\\n---------------------------------------------------------------------\";\n+\t\t\t$php_cgi_info = \"$php_info_sep\\nPHP         : $php_cgi $php_info_cgi$php_info_sep\";\n+\t\t} else {\n+\t\t\t$php_cgi_info = '';\n+\t\t}\n+\n+\t\t@unlink($info_file);\n+\n+\t\t// load list of enabled extensions\n+\t\tsave_text($info_file, '<?php echo join(\",\", get_loaded_extensions()); ?>');\n+\t\t$exts_to_test = explode(',',`$php $pass_options $info_params \"$info_file\"`);\n+\t\t// check for extensions that need special handling and regenerate\n+\t\t$info_params_ex = array(\n+\t\t\t'session' => array('session.auto_start=0'),\n+\t\t\t'tidy' => array('tidy.clean_output=0'),\n+\t\t\t'zlib' => array('zlib.output_compression=Off'),\n+\t\t\t'xdebug' => array('xdebug.default_enable=0'),\n+\t\t\t'mbstring' => array('mbstring.func_overload=0'),\n+\t\t);\n+\n+\t\tforeach($info_params_ex as $ext => $ini_overwrites_ex) {\n+\t\t\tif (in_array($ext, $exts_to_test)) {\n+\t\t\t\t$ini_overwrites = array_merge($ini_overwrites, $ini_overwrites_ex);\n+\t\t\t}\n+\t\t}\n+\n+\t\t@unlink($info_file);\n+\n+\t\t// Write test context information.\n+\t\techo \"\n+=====================================================================\n+PHP         : $php $php_info $php_cgi_info\n+CWD         : $cwd\n+Extra dirs  : \";\n+\t\tforeach ($user_tests as $test_dir) {\n+\t\t\techo \"{$test_dir}\\n              \";\n+\t\t}\n+\t\techo \"\n+VALGRIND    : \" . ($leak_check ? $valgrind_header : 'Not used') . \"\n+=====================================================================\n+\";\n+\t}\n+\n+\tdefine('QA_PROJECT', 'libgit2/php-git');\n+\tdefine('QA_API_PAGE', 'https://api.github.com/repos/');\n+\tdefine('QA_SUBMISSION_PAGE', 'http://report.phpgit.org/buildtest/process');\n+\tdefine('QA_REPORTS_PAGE', 'https://github.com/'.QA_PROJECT . '/issues');\n+\tdefine('TRAVIS_CI' , (bool) getenv('TRAVIS_PHP_VERSION'));\n+\n+\tfunction save_or_mail_results()\n+\t{\n+\t\tglobal $sum_results, $just_save_results, $failed_test_summary,\n+\t\t       $PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression;\n+\n+\t\t/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */\n+\t\tif (!getenv('NO_INTERACTION') && !TRAVIS_CI) {\n+\t\t\t$fp = fopen(\"php://stdin\", \"r+\");\n+\t\t\tif ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) {\n+\t\t\t\techo \"\\nYou may have found a problem in PHP.\";\n+\t\t\t}\n+\t\t\techo \"\\nThis report can be automatically sent to the php-Git issue tracker at\\n\";\n+\t\t\techo QA_REPORTS_PAGE . \"\\n\";\n+\t\t\techo \"This gives us a better understanding of php-git behavior.\\n\";\n+\t\t\techo \"If you don't want to send the report immediately you can choose\\n\";\n+\t\t\techo \"option \\\"s\\\" to save it.\tYou can then submit it to \". QA_REPORTS_PAGE . \" later.\\n\";\n+\t\t\techo \"Do you want to send this report now? [Yns]: \";\n+\t\t\tflush();\n+\n+\n+\t\t\t$user_input = fgets($fp, 10);\n+\t\t\t$just_save_results = (strtolower($user_input[0]) == 's');\n+\t\t}\n+\n+\t\tif ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) {\n+\t\t\tif ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {\n+\t\t\t\t/*\n+\t\t\t\t * Collect information about the host system for our report\n+\t\t\t\t * Fetch phpinfo() output so that we can see the PHP enviroment\n+\t\t\t\t * Make an archive of all the failed tests\n+\t\t\t\t * Send an email\n+\t\t\t\t */\n+\t\t\t\tif ($just_save_results) {\n+\t\t\t\t\t$user_input = 's';\n+\t\t\t\t}\n+\n+\t\t\t\t/* Ask the user to provide an email address, so that QA team can contact the user */\n+\t\t\t\t$failed_tests_data = '';\n+\t\t\t\t$sep = \"\\n\" . str_repeat('=', 80) . \"\\n\";\n+\t\t\t\t$failed_tests_data .= $failed_test_summary . \"\\n\";\n+\t\t\t\t$failed_tests_data .= get_summary(true, false) . \"\\n\";\n+\n+\t\t\t\tif ($sum_results['FAILED']) {\n+\t\t\t\t\tforeach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {\n+\t\t\t\t\t\t$failed_tests_data .= $sep . $test_info['name'] . $test_info['info'];\n+\t\t\t\t\t\t$failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']), FILE_BINARY);\n+\t\t\t\t\t\t$failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']), FILE_BINARY);\n+\t\t\t\t\t\t$failed_tests_data .= $sep . \"\\n\\n\";\n+\t\t\t\t\t}\n+\t\t\t\t\t$status = \"failed\";\n+\t\t\t\t} else {\n+\t\t\t\t\t$status = \"success\";\n+\t\t\t\t}\n+\n+\t\t\t\t$failed_tests_data .= \"\\n\" . $sep . 'BUILD ENVIRONMENT' . $sep;\n+\t\t\t\t$failed_tests_data .= \"OS:\\n\" . PHP_OS . \" - \" . php_uname() . \"\\n\\n\";\n+\t\t\t\t$ldd = $autoconf = $sys_libtool = $libtool = $compiler = 'N/A';\n+\n+\t\t\t\tif (substr(PHP_OS, 0, 3) != \"WIN\") {\n+\t\t\t\t\t/* If PHP_AUTOCONF is set, use it; otherwise, use 'autoconf'. */\n+\t\t\t\t\tif (getenv('PHP_AUTOCONF')) {\n+\t\t\t\t\t\t$autoconf = shell_exec(getenv('PHP_AUTOCONF') . ' --version');\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\t$autoconf = shell_exec('autoconf --version');\n+\t\t\t\t\t}\n+\n+\t\t\t\t\t/* Always use the generated libtool - Mac OSX uses 'glibtool' */\n+\t\t\t\t\t$libtool = shell_exec($CUR_DIR . '/libtool --version');\n+\n+\t\t\t\t\t/* Use shtool to find out if there is glibtool present (MacOSX) */\n+\t\t\t\t\t$sys_libtool_path = shell_exec(__DIR__ . '/build/shtool path glibtool libtool');\n+\n+\t\t\t\t\tif ($sys_libtool_path) {\n+\t\t\t\t\t\t$sys_libtool = shell_exec(str_replace(\"\\n\", \"\", $sys_libtool_path) . ' --version');\n+\t\t\t\t\t}\n+\n+\t\t\t\t\t/* Try the most common flags for 'version' */\n+\t\t\t\t\t$flags = array('-v', '-V', '--version');\n+\t\t\t\t\t$cc_status = 0;\n+\n+\t\t\t\t\tforeach($flags AS $flag) {\n+\t\t\t\t\t\tsystem(getenv('CC') . \" $flag >/dev/null 2>&1\", $cc_status);\n+\t\t\t\t\t\tif ($cc_status == 0) {\n+\t\t\t\t\t\t\t$compiler = shell_exec(getenv('CC') . \" $flag 2>&1\");\n+\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\n+\t\t\t\t\t$ldd = shell_exec(\"ldd $php 2>/dev/null\");\n+\t\t\t\t}\n+\n+\t\t\t\t$failed_tests_data .= \"Autoconf:\\n$autoconf\\n\";\n+\t\t\t\t$failed_tests_data .= \"Bundled Libtool:\\n$libtool\\n\";\n+\t\t\t\t$failed_tests_data .= \"System Libtool:\\n$sys_libtool\\n\";\n+\t\t\t\t$failed_tests_data .= \"Compiler:\\n$compiler\\n\";\n+\t\t\t\t$failed_tests_data .= \"Bison:\\n\". shell_exec('bison --version 2>/dev/null') . \"\\n\";\n+\t\t\t\t$failed_tests_data .= \"Libraries:\\n$ldd\\n\";\n+\t\t\t\t$failed_tests_data .= \"\\n\";\n+\n+\t\t\t\t$failed_tests_data .= $sep . \"PHPINFO\" . $sep;\n+\t\t\t\t$failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null');\n+\n+\t\t\t\tif ($just_save_results || !send_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) {\n+\t\t\t\t\tfile_put_contents($output_file, $failed_tests_data);\n+\n+\t\t\t\t\tif (!$just_save_results) {\n+\t\t\t\t\t\techo \"\\nThe test script was unable to automatically send the report to PHP's QA Team\\n\";\n+\t\t\t\t\t}\n+\n+\t\t\t\techo \"Please submit \" . $output_file . \" to \" . QA_REPORTS_PAGE . \" manually, thank you.\\n\";\n+\t\t\t\t} elseif (!getenv('NO_INTERACTION') && !TRAVIS_CI) {\n+\t\t\t\t\tfwrite($fp, \"\\nThank you for helping to make php-git better.\\n\");\n+\t\t\t\t\tfclose($fp);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t// Determine the tests to be run.\n+\n+\t$test_files = array();\n+\t$redir_tests = array();\n+\t$test_results = array();\n+\t$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array());\n+\n+\t// If parameters given assume they represent selected tests to run.\n+\t$failed_tests_file= false;\n+\t$pass_option_n = false;\n+\t$pass_options = '';\n+\n+\t$compression = 0;\n+\t$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';\n+\n+\tif ($compression && in_array(\"compress.zlib\", stream_get_filters())) {\n+\t\t$output_file = 'compress.zlib://' . $output_file . '.gz';\n+\t}\n+\n+\t$just_save_results = false;\n+\t$leak_check = false;\n+\t$html_output = false;\n+\t$html_file = null;\n+\t$temp_source = null;\n+\t$temp_target = null;\n+\t$temp_urlbase = null;\n+\t$conf_passed = null;\n+\t$no_clean = false;\n+\n+\t$cfgtypes = array('show', 'keep');\n+\t$cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp');\n+\t$cfg = array();\n+\n+\tforeach($cfgtypes as $type) {\n+\t\t$cfg[$type] = array();\n+\n+\t\tforeach($cfgfiles as $file) {\n+\t\t\t$cfg[$type][$file] = false;\n+\t\t}\n+\t}\n+\n+\tif (getenv('TEST_PHP_ARGS')) {\n+\n+\t\tif (!isset($argc) || !$argc || !isset($argv)) {\n+\t\t\t$argv = array(__FILE__);\n+\t\t}\n+\n+\t\t$argv = array_merge($argv, explode(' ', getenv('TEST_PHP_ARGS')));\n+\t\t$argc = count($argv);\n+\t}\n+\n+\tif (isset($argc) && $argc > 1) {\n+\n+\t\tfor ($i=1; $i<$argc; $i++) {\n+\t\t\t$is_switch = false;\n+\t\t\t$switch = substr($argv[$i],1,1);\n+\t\t\t$repeat = substr($argv[$i],0,1) == '-';\n+\n+\t\t\twhile ($repeat) {\n+\n+\t\t\t\tif (!$is_switch) {\n+\t\t\t\t\t$switch = substr($argv[$i],1,1);\n+\t\t\t\t}\n+\n+\t\t\t\t$is_switch = true;\n+\n+\t\t\t\tif ($repeat) {\n+\t\t\t\t\tforeach($cfgtypes as $type) {\n+\t\t\t\t\t\tif (strpos($switch, '--' . $type) === 0) {\n+\t\t\t\t\t\t\tforeach($cfgfiles as $file) {\n+\t\t\t\t\t\t\t\tif ($switch == '--' . $type . '-' . $file) {\n+\t\t\t\t\t\t\t\t\t$cfg[$type][$file] = true;\n+\t\t\t\t\t\t\t\t\t$is_switch = false;\n+\t\t\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\n+\t\t\t\tif (!$is_switch) {\n+\t\t\t\t\t$is_switch = true;\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\n+\t\t\t\t$repeat = false;\n+\n+\t\t\t\tswitch($switch) {\n+\t\t\t\t\tcase 'r':\n+\t\t\t\t\tcase 'l':\n+\t\t\t\t\t\t$test_list = file($argv[++$i]);\n+\t\t\t\t\t\tif ($test_list) {\n+\t\t\t\t\t\t\tforeach($test_list as $test) {\n+\t\t\t\t\t\t\t\t$matches = array();\n+\t\t\t\t\t\t\t\tif (preg_match('/^#.*\\[(.*)\\]\\:\\s+(.*)$/', $test, $matches)) {\n+\t\t\t\t\t\t\t\t\t$redir_tests[] = array($matches[1], $matches[2]);\n+\t\t\t\t\t\t\t\t} else if (strlen($test)) {\n+\t\t\t\t\t\t\t\t\t$test_files[] = trim($test);\n+\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tif ($switch != 'l') {\n+\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\t$i--;\n+\t\t\t\t\t// break left intentionally\n+\t\t\t\t\tcase 'w':\n+\t\t\t\t\t\t$failed_tests_file = fopen($argv[++$i], 'w+t');\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'a':\n+\t\t\t\t\t\t$failed_tests_file = fopen($argv[++$i], 'a+t');\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'c':\n+\t\t\t\t\t\t$conf_passed = $argv[++$i];\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'd':\n+\t\t\t\t\t\t$ini_overwrites[] = $argv[++$i];\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'g':\n+\t\t\t\t\t\t$SHOW_ONLY_GROUPS = explode(\",\", $argv[++$i]);;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\t//case 'h'\n+\t\t\t\t\tcase '--keep-all':\n+\t\t\t\t\t\tforeach($cfgfiles as $file) {\n+\t\t\t\t\t\t\t$cfg['keep'][$file] = true;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\t//case 'l'\n+\t\t\t\t\tcase 'm':\n+\t\t\t\t\t\t$leak_check = true;\n+\t\t\t\t\t\t$valgrind_cmd = \"valgrind --version\";\n+\t\t\t\t\t\t$valgrind_header = system_with_timeout($valgrind_cmd, $environment);\n+\t\t\t\t\t\t$replace_count = 0;\n+\t\t\t\t\t\tif (!$valgrind_header) {\n+\t\t\t\t\t\t\terror(\"Valgrind returned no version info, cannot proceed.\\nPlease check if Valgrind is installed.\");\n+\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\t$valgrind_version = preg_replace(\"/valgrind-(\\d)\\.(\\d)\\.(\\d+)([.\\w_-]+)?(\\s+)/\", '$1$2$3', $valgrind_header, 1, $replace_count);\n+\t\t\t\t\t\t\tif ($replace_count != 1 || !is_numeric($valgrind_version)) {\n+\t\t\t\t\t\t\t\terror(\"Valgrind returned invalid version info (\\\"$valgrind_header\\\"), cannot proceed.\");\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t$valgrind_header = trim($valgrind_header);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'n':\n+\t\t\t\t\t\tif (!$pass_option_n) {\n+\t\t\t\t\t\t\t$pass_options .= ' -n';\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\t$pass_option_n = true;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--no-clean':\n+\t\t\t\t\t\t$no_clean = true;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'p':\n+\t\t\t\t\t\t$php = $argv[++$i];\n+\t\t\t\t\t\tputenv(\"TEST_PHP_EXECUTABLE=$php\");\n+\t\t\t\t\t\t$environment['TEST_PHP_EXECUTABLE'] = $php;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'P':\n+\t\t\t\t\t\tif(constant('PHP_BINARY')) {\n+\t\t\t\t\t\t\t$php = PHP_BINARY;\n+\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tputenv(\"TEST_PHP_EXECUTABLE=$php\");\n+\t\t\t\t\t\t$environment['TEST_PHP_EXECUTABLE'] = $php;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'q':\n+\t\t\t\t\t\tputenv('NO_INTERACTION=1');\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\t//case 'r'\n+\t\t\t\t\tcase 's':\n+\t\t\t\t\t\t$output_file = $argv[++$i];\n+\t\t\t\t\t\t$just_save_results = true;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--set-timeout':\n+\t\t\t\t\t\t$environment['TEST_TIMEOUT'] = $argv[++$i];\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--show-all':\n+\t\t\t\t\t\tforeach($cfgfiles as $file) {\n+\t\t\t\t\t\t\t$cfg['show'][$file] = true;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--temp-source':\n+\t\t\t\t\t\t$temp_source = $argv[++$i];\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--temp-target':\n+\t\t\t\t\t\t$temp_target = $argv[++$i];\n+\t\t\t\t\t\tif ($temp_urlbase) {\n+\t\t\t\t\t\t\t$temp_urlbase = $temp_target;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--temp-urlbase':\n+\t\t\t\t\t\t$temp_urlbase = $argv[++$i];\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'v':\n+\t\t\t\t\tcase '--verbose':\n+\t\t\t\t\t\t$DETAILED = true;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase 'x':\n+\t\t\t\t\t\t$environment['SKIP_SLOW_TESTS'] = 1;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--offline':\n+\t\t\t\t\t\t$environment['SKIP_ONLINE_TESTS'] = 1;\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\t//case 'w'\n+\t\t\t\t\tcase '-':\n+\t\t\t\t\t\t// repeat check with full switch\n+\t\t\t\t\t\t$switch = $argv[$i];\n+\t\t\t\t\t\tif ($switch != '-') {\n+\t\t\t\t\t\t\t$repeat = true;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--html':\n+\t\t\t\t\t\t$html_file = fopen($argv[++$i], 'wt');\n+\t\t\t\t\t\t$html_output = is_resource($html_file);\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tcase '--version':\n+\t\t\t\t\t\techo '$Id: 305b48d9335b7fa38b96d023fd21bdbb2e6e52a9 $' . \"\\n\";\n+\t\t\t\t\t\texit(1);\n+\n+\t\t\t\t\tdefault:\n+\t\t\t\t\t\techo \"Illegal switch '$switch' specified!\\n\";\n+\t\t\t\t\tcase 'h':\n+\t\t\t\t\tcase '-help':\n+\t\t\t\t\tcase '--help':\n+\t\t\t\t\t\techo <<<HELP\n+Synopsis:\n+    php run-tests.php [options] [files] [directories]\n+\n+Options:\n+    -l <file>   Read the testfiles to be executed from <file>. After the test\n+                has finished all failed tests are written to the same <file>.\n+                If the list is empty and no further test is specified then\n+                all tests are executed (same as: -r <file> -w <file>).\n+\n+    -r <file>   Read the testfiles to be executed from <file>.\n+\n+    -w <file>   Write a list of all failed tests to <file>.\n+\n+    -a <file>   Same as -w but append rather then truncating <file>.\n+\n+    -c <file>   Look for php.ini in directory <file> or use <file> as ini.\n+\n+    -n          Pass -n option to the php binary (Do not use a php.ini).\n+\n+    -d foo=bar  Pass -d option to the php binary (Define INI entry foo\n+                with value 'bar').\n+\n+    -g          Comma separated list of groups to show during test run\n+                (possible values: PASS, FAIL, XFAIL, SKIP, BORK, WARN, LEAK, REDIRECT).\n+\n+    -m          Test for memory leaks with Valgrind.\n+\n+    -p <php>    Specify PHP executable to run.\n+\n+    -P          Use PHP_BINARY as PHP executable to run.\n+\n+    -q          Quiet, no user interaction (same as environment NO_INTERACTION).\n+\n+    -s <file>   Write output to <file>.\n+\n+    -x          Sets 'SKIP_SLOW_TESTS' environmental variable.\n+\n+    --offline   Sets 'SKIP_ONLINE_TESTS' environmental variable.\n+\n+    --verbose\n+    -v          Verbose mode.\n+\n+    --help\n+    -h          This Help.\n+\n+    --html <file> Generate HTML output.\n+\n+    --temp-source <sdir>  --temp-target <tdir> [--temp-urlbase <url>]\n+                Write temporary files to <tdir> by replacing <sdir> from the\n+                filenames to generate with <tdir>. If --html is being used and\n+                <url> given then the generated links are relative and prefixed\n+                with the given url. In general you want to make <sdir> the path\n+                to your source files and <tdir> some pach in your web page\n+                hierarchy with <url> pointing to <tdir>.\n+\n+    --keep-[all|php|skip|clean]\n+                Do not delete 'all' files, 'php' test file, 'skip' or 'clean'\n+                file.\n+\n+    --set-timeout [n]\n+                Set timeout for individual tests, where [n] is the number of\n+                seconds. The default value is 60 seconds, or 300 seconds when\n+                testing for memory leaks.\n+\n+    --show-[all|php|skip|clean|exp|diff|out]\n+                Show 'all' files, 'php' test file, 'skip' or 'clean' file. You\n+                can also use this to show the output 'out', the expected result\n+                'exp' or the difference between them 'diff'. The result types\n+                get written independent of the log format, however 'diff' only\n+                exists when a test fails.\n+\n+    --no-clean  Do not execute clean section if any.\n+\n+HELP;\n+\t\t\t\t\t\texit(1);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif (!$is_switch) {\n+\t\t\t\t$testfile = realpath($argv[$i]);\n+\n+\t\t\t\tif (!$testfile && strpos($argv[$i], '*') !== false && function_exists('glob')) {\n+\n+\t\t\t\t\tif (preg_match(\"/\\.phpt$/\", $argv[$i])) {\n+\t\t\t\t\t\t$pattern_match = glob($argv[$i]);\n+\t\t\t\t\t} else if (preg_match(\"/\\*$/\", $argv[$i])) {\n+\t\t\t\t\t\t$pattern_match = glob($argv[$i] . '.phpt');\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\tdie(\"bogus test name \" . $argv[$i] . \"\\n\");\n+\t\t\t\t\t}\n+\n+\t\t\t\t\tif (is_array($pattern_match)) {\n+\t\t\t\t\t\t$test_files = array_merge($test_files, $pattern_match);\n+\t\t\t\t\t}\n+\n+\t\t\t\t} else if (is_dir($testfile)) {\n+\t\t\t\t\tfind_files($testfile);\n+\t\t\t\t} else if (preg_match(\"/\\.phpt$/\", $testfile)) {\n+\t\t\t\t\t$test_files[] = $testfile;\n+\t\t\t\t} else {\n+\t\t\t\t\tdie(\"bogus test name \" . $argv[$i] . \"\\n\");\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (strlen($conf_passed)) {\n+\t\t\tif (substr(PHP_OS, 0, 3) == \"WIN\") {\n+\t\t\t\t$pass_options .= \" -c \" . escapeshellarg($conf_passed);\n+\t\t\t} else {\n+\t\t\t\t$pass_options .= \" -c '$conf_passed'\";\n+\t\t\t}\n+\t\t}\n+\n+\t\t$test_files = array_unique($test_files);\n+\t\t$test_files = array_merge($test_files, $redir_tests);\n+\n+\t\t// Run selected tests.\n+\t\t$test_cnt = count($test_files);\n+\n+\t\tif ($test_cnt) {\n+\t\t\tputenv('NO_INTERACTION=1');\n+\t\t\tverify_config();\n+\t\t\twrite_information($html_output);\n+\t\t\tusort($test_files, \"test_sort\");\n+\t\t\t$start_time = time();\n+\n+\t\t\tif (!$html_output) {\n+\t\t\t\techo \"Running selected tests.\\n\";\n+\t\t\t} else {\n+\t\t\t\tshow_start($start_time);\n+\t\t\t}\n+\n+\t\t\t$test_idx = 0;\n+\t\t\trun_all_tests($test_files, $environment);\n+\t\t\t$end_time = time();\n+\n+\t\t\tif ($html_output) {\n+\t\t\t\tshow_end($end_time);\n+\t\t\t}\n+\n+\t\t\tif ($failed_tests_file) {\n+\t\t\t\tfclose($failed_tests_file);\n+\t\t\t}\n+\n+\t\t\tcompute_summary();\n+\t\t\tif ($html_output) {\n+\t\t\t\tfwrite($html_file, \"<hr/>\\n\" . get_summary(false, true));\n+\t\t\t}\n+\t\t\techo \"=====================================================================\";\n+\t\t\techo get_summary(false, false);\n+\n+\t\t\tif ($html_output) {\n+\t\t\t\tfclose($html_file);\n+\t\t\t}\n+\n+\t\t\tif ($output_file != '' && $just_save_results) {\n+\t\t\t\tsave_or_mail_results();\n+\t\t\t}\n+\n+\t\t\tjunit_save_xml();\n+\n+\t\t\tif (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {\n+\t\t\t\texit(1);\n+\t\t\t}\n+\n+\t\t\texit(0);\n+\t\t}\n+\t}\n+\n+\tverify_config();\n+\twrite_information($html_output);\n+\n+\t// Compile a list of all test files (*.phpt).\n+\t$test_files = array();\n+\t$exts_tested = count($exts_to_test);\n+\t$exts_skipped = 0;\n+\t$ignored_by_ext = 0;\n+\tsort($exts_to_test);\n+\t$test_dirs = array();\n+\t$optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 'sapi/cgi');\n+\n+\tforeach($optionals as $dir) {\n+\t\tif (@filetype($dir) == 'dir') {\n+\t\t\t$test_dirs[] = $dir;\n+\t\t}\n+\t}\n+\n+\t// Convert extension names to lowercase\n+\tforeach ($exts_to_test as $key => $val) {\n+\t\t$exts_to_test[$key] = strtolower($val);\n+\t}\n+\n+\tforeach ($test_dirs as $dir) {\n+\t\tfind_files(\"{$cwd}/{$dir}\", ($dir == 'ext'));\n+\t}\n+\n+\tforeach ($user_tests as $dir) {\n+\t\tfind_files($dir, ($dir == 'ext'));\n+\t}\n+\n+\tfunction find_files($dir, $is_ext_dir = false, $ignore = false)\n+\t{\n+\t\tglobal $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested;\n+\n+\t\t$o = opendir($dir) or error(\"cannot open directory: $dir\");\n+\n+\t\twhile (($name = readdir($o)) !== false) {\n+\n+\t\t\tif (is_dir(\"{$dir}/{$name}\") && !in_array($name, array('.', '..', '.svn'))) {\n+\t\t\t\t$skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test));\n+\t\t\t\tif ($skip_ext) {\n+\t\t\t\t\t$exts_skipped++;\n+\t\t\t\t}\n+\t\t\t\tfind_files(\"{$dir}/{$name}\", false, $ignore || $skip_ext);\n+\t\t\t}\n+\n+\t\t\t// Cleanup any left-over tmp files from last run.\n+\t\t\tif (substr($name, -4) == '.tmp') {\n+\t\t\t\t@unlink(\"$dir/$name\");\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\t// Otherwise we're only interested in *.phpt files.\n+\t\t\tif (substr($name, -5) == '.phpt') {\n+\t\t\t\tif ($ignore) {\n+\t\t\t\t\t$ignored_by_ext++;\n+\t\t\t\t} else {\n+\t\t\t\t\t$testfile = realpath(\"{$dir}/{$name}\");\n+\t\t\t\t\t$test_files[] = $testfile;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\n+\t\tclosedir($o);\n+\t}\n+\n+\tfunction test_name($name)\n+\t{\n+\t\tif (is_array($name)) {\n+\t\t\treturn $name[0] . ':' . $name[1];\n+\t\t} else {\n+\t\t\treturn $name;\n+\t\t}\n+\t}\n+\n+\tfunction test_sort($a, $b)\n+\t{\n+\t\tglobal $cwd;\n+\n+\t\t$a = test_name($a);\n+\t\t$b = test_name($b);\n+\n+\t\t$ta = strpos($a, \"{$cwd}/tests\") === 0 ? 1 + (strpos($a, \"{$cwd}/tests/run-test\") === 0 ? 1 : 0) : 0;\n+\t\t$tb = strpos($b, \"{$cwd}/tests\") === 0 ? 1 + (strpos($b, \"{$cwd}/tests/run-test\") === 0 ? 1 : 0) : 0;\n+\n+\t\tif ($ta == $tb) {\n+\t\t\treturn strcmp($a, $b);\n+\t\t} else {\n+\t\t\treturn $tb - $ta;\n+\t\t}\n+\t}\n+\n+\t$test_files = array_unique($test_files);\n+\tusort($test_files, \"test_sort\");\n+\n+\t$start_time = time();\n+\tshow_start($start_time);\n+\n+\t$test_cnt = count($test_files);\n+\t$test_idx = 0;\n+\trun_all_tests($test_files, $environment);\n+\t$end_time = time();\n+\n+\tif ($failed_tests_file) {\n+\t\tfclose($failed_tests_file);\n+\t}\n+\n+\t// Summarize results\n+\n+\tif (0 == count($test_results)) {\n+\t\techo \"No tests were run.\\n\";\n+\t\treturn;\n+\t}\n+\n+\tcompute_summary();\n+\n+\tshow_end($end_time);\n+\tshow_summary();\n+\n+\tif ($html_output) {\n+\t\tfclose($html_file);\n+\t}\n+\n+\tsave_or_mail_results();\n+\n+\tjunit_save_xml();\n+\n+\tif (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {\n+\t\texit(1);\n+\t}\n+\texit(0);\n+\n+\t//\n+\t// Send Email to QA Team\n+\t//\n+\n+\tfunction send_qa_team($data, $compression, $status = false)\n+\t{\n+\t\t$php_version = urlencode(TESTED_PHP_VERSION);\n+\t\t$dataArray = array(\n+\t\t\t'status' => $status,\n+\t\t\t'version' => $php_version,\n+\t\t\t'php_test_data' => base64_encode(str_replace(\"\\00\", '[0x0]', $data))\n+\t\t);\n+\n+\n+\t\t$url = QA_SUBMISSION_PAGE;\n+\t\techo \"\\nPosting to \". $url . \"\\n\";\n+\n+\n+\t\t$ch = curl_init();","path":"run-tests.php.in","position":983,"original_position":983,"commit_id":"8eeeb5343fbabdd44bf721d7214566155cace26c","original_commit_id":"8eeeb5343fbabdd44bf721d7214566155cace26c","user":{"login":"chobie","id":195038,"avatar_url":"https://avatars.githubusercontent.com/u/195038?","gravatar_id":"27520341fe306fbf038eec7cd64466e4","url":"https://api.github.com/users/chobie","html_url":"https://github.com/chobie","followers_url":"https://api.github.com/users/chobie/followers","following_url":"https://api.github.com/users/chobie/following{/other_user}","gists_url":"https://api.github.com/users/chobie/gists{/gist_id}","starred_url":"https://api.github.com/users/chobie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chobie/subscriptions","organizations_url":"https://api.github.com/users/chobie/orgs","repos_url":"https://api.github.com/users/chobie/repos","events_url":"https://api.github.com/users/chobie/events{/privacy}","received_events_url":"https://api.github.com/users/chobie/received_events","type":"User","site_admin":false},"body":"Some distribution didn't budle curl extension (for instance: debian, ubuntu).  I think it will be better to use original code.","created_at":"2014-05-16T15:08:56Z","updated_at":"2014-05-16T15:08:56Z","html_url":"https://github.com/libgit2/php-git/pull/71#discussion_r12742879","pull_request_url":"https://api.github.com/repos/libgit2/php-git/pulls/71","_links":{"self":{"href":"https://api.github.com/repos/libgit2/php-git/pulls/comments/12742879"},"html":{"href":"https://github.com/libgit2/php-git/pull/71#discussion_r12742879"},"pull_request":{"href":"https://api.github.com/repos/libgit2/php-git/pulls/71"}}}}