diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 09a7aad..b2e55ca 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -17,6 +17,7 @@ use Drupal\simpletest\Form\SimpletestResultsForm; use Drupal\simpletest\TestBase; use Drupal\simpletest\TestDiscovery; +use Symfony\Component\Process\PhpExecutableFinder; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -446,15 +447,14 @@ function simpletest_script_init() { // that was executed. $php = $php_env; } - elseif ($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. - list($php) = explode(' ', $sudo, 2); - } else { - 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); + $php_executable_finder = new PhpExecutableFinder(); + $php = $php_executable_finder->find(); + if ($php == FALSE) { + 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); + } } // Get URL from arguments. @@ -824,7 +824,7 @@ function simpletest_script_run_one_test($test_id, $test_class) { function simpletest_script_command($test_id, $test_class) { global $args, $php; - $command = escapeshellarg($php) . ' ' . escapeshellarg('./core/scripts/' . $args['script']); + $command = $php . ' ' . escapeshellarg('./core/scripts/' . $args['script']); $command .= ' --url ' . escapeshellarg($args['url']); if (!empty($args['sqlite'])) { $command .= ' --sqlite ' . escapeshellarg($args['sqlite']);