From 9a45eeadd6c8c0be30881706d1ce8c3cd3069132 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 7 Jun 2022 13:11:28 +0100 Subject: [PATCH] Fix GH-8691 Add required extensions for redirected tests --- run-tests.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 0a091d5d8af95..7df5aebf47dfc 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2010,11 +2010,19 @@ function run_test(string $php, $file, array $env): string $ini_settings = $workerID ? ['opcache.cache_id' => "worker$workerID"] : []; // Additional required extensions + $extensions = []; if ($test->hasSection('EXTENSIONS')) { + $extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS'))); + } + if (is_array($IN_REDIRECT) && $IN_REDIRECT['EXTENSIONS'] != []) { + $extensions = array_merge($extensions, $IN_REDIRECT['EXTENSIONS']); + } + + /* Load required extensions */ + if ($extensions != []) { $ext_params = []; settings2array($ini_overwrites, $ext_params); $ext_params = settings2params($ext_params); - $extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS'))); [$ext_dir, $loaded] = $skipCache->getExtensions("$orig_php $pass_options $extra_options $ext_params $no_file_cache"); $ext_prefix = IS_WINDOWS ? "php_" : ""; $missing = []; @@ -2166,6 +2174,7 @@ function run_test(string $php, $file, array $env): string $IN_REDIRECT['via'] = "via [$shortname]\n\t"; $IN_REDIRECT['dir'] = realpath(dirname($file)); $IN_REDIRECT['prefix'] = $tested; + $IN_REDIRECT['EXTENSIONS'] = $extensions; if (!empty($IN_REDIRECT['TESTS'])) { if (is_array($org_file)) { @@ -3323,6 +3332,9 @@ class JUnit 'execution_time' => 0, ]; + /** + * @throws Exception + */ public function __construct(array $env, int $workerID) { // Check whether a junit log is wanted. @@ -3540,6 +3552,9 @@ public function initSuite(string $suite_name): void $this->suites[$suite_name] = self::EMPTY_SUITE + ['name' => $suite_name]; } + /** + * @throws Exception + */ public function stopTimer(string $file_name): void { if (!$this->enabled) { @@ -3739,6 +3754,9 @@ class TestFile 'CREDITS', 'DESCRIPTION', 'CONFLICTS', 'WHITESPACE_SENSITIVE', ]; + /** + * @throws BorkageException + */ public function __construct(string $fileName, bool $inRedirect) { $this->fileName = $fileName; @@ -3779,6 +3797,9 @@ public function sectionNotEmpty(string $name): bool return !empty($this->sections[$name]); } + /** + * @throws Exception + */ public function getSection(string $name): string { if (!isset($this->sections[$name])) { @@ -3815,6 +3836,7 @@ public function setSection(string $name, string $value): void /** * Load the sections of the test file + * @throws BorkageException */ private function readFile(): void { @@ -3877,6 +3899,9 @@ private function readFile(): void fclose($fp); } + /** + * @throws BorkageException + */ private function validateAndProcess(bool $inRedirect): void { // the redirect section allows a set of tests to be reused outside of