From b96202277f559ae2e55b1f6490478079e01d837b Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Thu, 29 Oct 2026 14:56:33 +0100 Subject: [PATCH 1/3] run-tests: Add skipif() helper for SKIPIF sections Provide skipif($condition, $reason) via auto_prepend_file as a clearer alternative to die('skip ...'). Convert a few tests and replace the conflicting local skipif() helpers in ext/xml and windows_acls tests. --- Zend/tests/bug74093.phpt | 8 ++--- Zend/tests/new_oom.phpt | 4 +-- .../tests/file/windows_acls/bug44859.phpt | 2 +- .../tests/file/windows_acls/bug44859_2.phpt | 2 +- .../tests/file/windows_acls/bug44859_3.phpt | 2 +- .../tests/file/windows_acls/bug44859_4.phpt | 2 +- .../tests/file/windows_acls/common.inc | 18 ++++------- ext/xml/tests/bug26614.phpt | 2 +- ext/xml/tests/bug26614_libxml_gte2_11.phpt | 4 +-- ext/xml/tests/bug26614_libxml_pre2_11.phpt | 4 +-- ext/xml/tests/bug81481.phpt | 8 ++--- ext/xml/tests/gh14834.phpt | 2 +- ext/xml/tests/gh20439_2.phpt | 2 +- ext/xml/tests/libxml_expat_skipif.inc | 7 ++-- .../tests/xml_error_string_basic_expat.phpt | 2 +- .../tests/xml_error_string_basic_libxml.phpt | 2 +- ...rt_namespace_decl_handler_basic_expat.phpt | 2 +- ...t_namespace_decl_handler_basic_libxml.phpt | 2 +- run-tests.php | 32 ++++++++++++++++++- 19 files changed, 64 insertions(+), 43 deletions(-) diff --git a/Zend/tests/bug74093.phpt b/Zend/tests/bug74093.phpt index fea0d5ea9d03..e1c08cb21941 100644 --- a/Zend/tests/bug74093.phpt +++ b/Zend/tests/bug74093.phpt @@ -3,10 +3,10 @@ Bug #74093 (Maximum execution time of n+2 seconds exceed not written in error_lo --FLAKY-- --SKIPIF-- --INI-- memory_limit=1G diff --git a/Zend/tests/new_oom.phpt b/Zend/tests/new_oom.phpt index 6d4ba3d760b4..1be334ad8f51 100644 --- a/Zend/tests/new_oom.phpt +++ b/Zend/tests/new_oom.phpt @@ -2,8 +2,8 @@ Test OOM on new of each class --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- = 2.11'); +skipif(xml_uses_expat(), 'test is for libxml'); +skipif(LIBXML_VERSION < 21100, 'libxml2 test variant for version >= 2.11'); ?> --FILE-- = 21100) die('skip libxml2 test variant for version < 2.11'); +skipif(xml_uses_expat(), 'test is for libxml'); +skipif(LIBXML_VERSION >= 21100, 'libxml2 test variant for version < 2.11'); ?> --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- Date: Thu, 29 Oct 2026 15:39:05 +0100 Subject: [PATCH 2/3] run-tests: Create SKIPIF helpers file with tempnam() A predictable name in the shared temp dir let other users plant a file whose code would run in every SKIPIF. --- .../tests/file/windows_acls/common.inc | 3 +-- run-tests.php | 22 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ext/standard/tests/file/windows_acls/common.inc b/ext/standard/tests/file/windows_acls/common.inc index 07d191524314..67051060eeee 100644 --- a/ext/standard/tests/file/windows_acls/common.inc +++ b/ext/standard/tests/file/windows_acls/common.inc @@ -12,8 +12,7 @@ define('PHPT_ACL_DENY', 2); function skip_unless_acl_testable() { skipif(substr(PHP_OS, 0, 3) != 'WIN', 'windows only test'); skipif(stripos(php_uname(), 'XP') !== FALSE, 'windows 2003 or newer only test'); - // bug44859_4.phpt test fails on the 1st run - // other ACL tests cannot be run twice + // bug44859_4.phpt fails on the 1st run; other ACL tests cannot be run twice skipif(getenv('GITHUB_ACTIONS'), 'failing on Github Actions'); } diff --git a/run-tests.php b/run-tests.php index 73631a628b26..a587be0fd787 100755 --- a/run-tests.php +++ b/run-tests.php @@ -179,6 +179,7 @@ function main(): void } define('TEST_PHP_SRCDIR', getcwd()); + define('SKIPIF_HELPERS_FILE', write_skipif_helpers()); check_proc_open_function_exists(); @@ -1249,13 +1250,8 @@ function test_sort($a, $b): int } // Functions available to every SKIPIF section via auto_prepend_file. -function skipif_helpers_file(): string +function write_skipif_helpers(): string { - static $file; - if ($file !== null) { - return $file; - } - $code = <<<'PHP' @unlink($file)); return $file; } @@ -1666,6 +1661,7 @@ function run_all_tests_parallel(array $test_files, array $env, ?string $redir_te "constants" => [ "INIT_DIR" => INIT_DIR, "TEST_PHP_SRCDIR" => TEST_PHP_SRCDIR, + "SKIPIF_HELPERS_FILE" => SKIPIF_HELPERS_FILE, ] ])) . "\n"; @@ -3930,7 +3926,7 @@ public function checkSkip(array $command, string $code, string $checkFile, strin save_text($checkFile, $code, $tempFile); $env['TEST_PHP_EVALUATING_SKIPIF'] = '1'; - array_push($command, '-d', 'auto_prepend_file=' . skipif_helpers_file(), $checkFile); + array_push($command, '-d', 'auto_prepend_file=' . SKIPIF_HELPERS_FILE, $checkFile); $result = trim(system_with_timeout($command, $env)); if (strpos($result, 'nocache') === 0) { $result = ''; From 7a3b79e5360e87019655a22bc187e0f11e28fb0f Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sat, 31 Oct 2026 17:47:33 +0100 Subject: [PATCH 3/3] run-tests: Inline skipif() helper into SKIPIF files phpdbg ignores auto_prepend_file, so skipif() was undefined in SKIPIF of phpdbg tests. --- run-tests.php | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/run-tests.php b/run-tests.php index a587be0fd787..abda538ecf4f 100755 --- a/run-tests.php +++ b/run-tests.php @@ -179,7 +179,6 @@ function main(): void } define('TEST_PHP_SRCDIR', getcwd()); - define('SKIPIF_HELPERS_FILE', write_skipif_helpers()); check_proc_open_function_exists(); @@ -1249,30 +1248,6 @@ function test_sort($a, $b): int return $tb - $ta; } -// Functions available to every SKIPIF section via auto_prepend_file. -function write_skipif_helpers(): string -{ - $code = <<<'PHP' - @unlink($file)); - return $file; -} - // // Write the given text to a temporary file. // @@ -1661,7 +1636,6 @@ function run_all_tests_parallel(array $test_files, array $env, ?string $redir_te "constants" => [ "INIT_DIR" => INIT_DIR, "TEST_PHP_SRCDIR" => TEST_PHP_SRCDIR, - "SKIPIF_HELPERS_FILE" => SKIPIF_HELPERS_FILE, ] ])) . "\n"; @@ -3892,6 +3866,9 @@ private function mergeSuites(array &$dest, array $source): void class SkipCache { + // Kept on one line so SKIPIF line numbers are unchanged. + private const HELPERS = ''; + private bool $enable; private bool $keepFile; @@ -3919,14 +3896,14 @@ public function checkSkip(array $command, string $code, string $checkFile, strin if (isset($this->skips[$key][$code])) { $this->hits++; if ($this->keepFile) { - save_text($checkFile, $code, $tempFile); + save_text($checkFile, self::HELPERS . $code, $tempFile); } return $this->skips[$key][$code]; } - save_text($checkFile, $code, $tempFile); + save_text($checkFile, self::HELPERS . $code, $tempFile); $env['TEST_PHP_EVALUATING_SKIPIF'] = '1'; - array_push($command, '-d', 'auto_prepend_file=' . SKIPIF_HELPERS_FILE, $checkFile); + $command[] = $checkFile; $result = trim(system_with_timeout($command, $env)); if (strpos($result, 'nocache') === 0) { $result = '';