summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorGerard Roche <gerardroche@users.noreply.github.com>2020-05-20 20:20:06 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-05-22 09:58:04 +0200
commitd1dde094f2442b11808bd77bc8b064be3792458a (patch)
treea1d0762731f5ab9388f25b4a2b3aed6778f3eaec /run-tests.php
parent2ef88f517d218ef0f9324622f06209c59138a634 (diff)
downloadphp-git-d1dde094f2442b11808bd77bc8b064be3792458a.tar.gz
run-tests: refactor
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php77
1 files changed, 48 insertions, 29 deletions
diff --git a/run-tests.php b/run-tests.php
index 51a82aad64..0a2f592c8c 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -159,24 +159,14 @@ function main()
define('INIT_DIR', getcwd());
- // change into the PHP source directory.
+ // Change into the PHP source directory.
if (getenv('TEST_PHP_SRCDIR')) {
@chdir(getenv('TEST_PHP_SRCDIR'));
}
- define('TEST_PHP_SRCDIR', getcwd());
- if (!function_exists('proc_open')) {
- echo <<<NO_PROC_OPEN_ERROR
+ define('TEST_PHP_SRCDIR', getcwd());
-+-----------------------------------------------------------+
-| ! ERROR ! |
-| The test-suite requires that proc_open() is available. |
-| Please check if you disabled it in php.ini. |
-+-----------------------------------------------------------+
-
-NO_PROC_OPEN_ERROR;
- exit(1);
- }
+ check_proc_open_function_exists();
// If timezone is not set, use UTC.
if (ini_get('date.timezone') == '') {
@@ -193,35 +183,36 @@ NO_PROC_OPEN_ERROR;
ini_set('pcre.backtrack_limit', PHP_INT_MAX);
- // delete as much output buffers as possible
- while (@ob_end_clean()) {
- }
- if (ob_get_level()) {
- echo "Not all buffers were deleted.\n";
- }
+ init_output_buffers();
error_reporting(E_ALL);
$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
+
+ // Some configurations like php.ini-development set variables_order="GPCS"
+ // not "EGPCS", in which case $_ENV is NOT populated. Detect if the $_ENV
+ // was empty and handle it by explicitly populating through getenv().
if (empty($environment)) {
- // not documented, but returns array of all environment variables
$environment = getenv();
}
+
if (empty($environment['TEMP'])) {
$environment['TEMP'] = sys_get_temp_dir();
if (empty($environment['TEMP'])) {
- // for example, OpCache on Windows will fail in this case because child processes (for tests) will not get
- // a TEMP variable, so GetTempPath() will fallback to c:\windows, while GetTempPath() will return %TEMP% for parent
- // (likely a different path). The parent will initialize the OpCache in that path, and child will fail to reattach to
- // the OpCache because it will be using the wrong path.
+ // For example, OpCache on Windows will fail in this case because
+ // child processes (for tests) will not get a TEMP variable, so
+ // GetTempPath() will fallback to c:\windows, while GetTempPath()
+ // will return %TEMP% for parent (likely a different path). The
+ // parent will initialize the OpCache in that path, and child will
+ // fail to reattach to the OpCache because it will be using the
+ // wrong path.
die("TEMP environment is NOT set");
} else {
if (count($environment) == 1) {
- // not having other environment variables, only having TEMP, is probably ok, but strange and may make a
- // difference in the test pass rate, so warn the user.
+ // 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;
}
}
@@ -1417,7 +1408,8 @@ function run_all_tests_parallel($test_files, $env, $redir_tested)
if ($shuffle) {
shuffle($test_files);
}
- /* Don't start more workers than test files */
+
+ // Don't start more workers than test files.
$workers = max(1, min($workers, count($test_files)));
echo "Spawning workers… ";
@@ -3700,4 +3692,31 @@ class RuntestsValgrind
}
}
+function init_output_buffers()
+{
+ // Delete as much output buffers as possible.
+ while (@ob_end_clean()) {
+ }
+
+ if (ob_get_level()) {
+ echo "Not all buffers were deleted.\n";
+ }
+}
+
+function check_proc_open_function_exists()
+{
+ if (!function_exists('proc_open')) {
+ echo <<<NO_PROC_OPEN_ERROR
+
++-----------------------------------------------------------+
+| ! ERROR ! |
+| The test-suite requires that proc_open() is available. |
+| Please check if you disabled it in php.ini. |
++-----------------------------------------------------------+
+
+NO_PROC_OPEN_ERROR;
+ exit(1);
+ }
+}
+
main();