diff options
Diffstat (limited to 'core/scripts/run-tests.sh')
-rwxr-xr-x | core/scripts/run-tests.sh | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 39a1ae4fee0a..4d93808ae596 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -479,23 +479,34 @@ function simpletest_script_init() { $host = 'localhost'; $path = ''; $port = '80'; + $php = ""; // Determine location of php command automatically, unless a command line // argument is supplied. - if (!empty($args['php'])) { - $php = $args['php']; - } - elseif ($php_env = getenv('_')) { + if ($php_env = getenv('_')) { // '_' is an environment variable set by the shell. It contains the command // that was executed. $php = $php_env; } - elseif ($sudo = getenv('SUDO_COMMAND')) { + + if ($sudo = getenv('SUDO_COMMAND')) { // 'SUDO_COMMAND' is an environment variable set by the sudo program. - // Extract only the PHP interpreter, not the rest of the command. - [$php] = explode(' ', $sudo, 2); + // This will be set if the script is run directly by sudo or if the + // script is run under a shell started by sudo. + if (str_contains($sudo, basename(__FILE__))) { + // This script may have been directly run by sudo. $php may have the + // path to sudo from getenv('_') if run with the -E option. + // Extract what may be the PHP interpreter. + [$php] = explode(' ', $sudo, 2); + } } - else { + + if (!empty($args['php'])) { + // Caller has specified path to php. Override auto-detection. + $php = $args['php']; + } + + if ($php == "") { simpletest_script_print_error('Unable to automatically determine the path to the PHP interpreter. Supply the --php command line argument.'); simpletest_script_help(); exit(SIMPLETEST_SCRIPT_EXIT_FAILURE); @@ -1161,7 +1172,7 @@ function place_tests_into_bins(array $tests, int $bin_count) { * Initialize the reporter. */ function simpletest_script_reporter_init() { - global $args, $test_list, $results_map; + global $args, $test_list, $results_map, $php; $results_map = [ 'pass' => 'Pass', @@ -1171,6 +1182,7 @@ function simpletest_script_reporter_init() { echo "\n"; echo "Drupal test run\n"; + echo "Using PHP Binary: $php\n"; echo "---------------\n"; echo "\n"; |