[php-src] master: run-tests: Clean the file cache directory in --file-cache-prime (#22784)

From: Date: Fri, 17 Jul 2026 17:33:20 +0000
Subject: [php-src] master: run-tests: Clean the file cache directory in --file-cache-prime (#22784)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140081@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2026-07-17T19:33:17+02:00 Commit: https://github.com/php/php-src/commit/d79a32d26345221a284eea1abab5b05803d8bc6a Raw diff: https://github.com/php/php-src/commit/d79a32d26345221a284eea1abab5b05803d8bc6a.diff run-tests: Clean the file cache directory in --file-cache-prime (#22784) run-tests.php --file-cache-prime sets opcache.file_cache to /tmp which makes it difficult to clear the cache. Set opcache.file_cache to /tmp/php-run-tests-file-cache, and clear the directory when --file-cache-prime is specified. Changed paths: M run-tests.php Diff: diff --git a/run-tests.php b/run-tests.php index f5c7be8b4f45..1d8be660388d 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1054,6 +1054,32 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false) closedir($o); } +function rmdir_recursive($dir) +{ + if (!file_exists($dir)) { + return; + } + if (!is_dir($dir)) { + unlink($dir); + return; + } + + $dh = opendir($dir); + if (!$dh) { + return; + } + + while (($entry = readdir($dh)) !== false) { + if ($entry === '.' || $entry === '..') { + continue; + } + rmdir_recursive($dir . DIRECTORY_SEPARATOR . $entry); + } + + closedir($dh); + rmdir($dir); +} + /** * @param array|string $name */ @@ -2065,7 +2091,11 @@ function run_test(string $php, $file, array $env): string $orig_ini_settings = settings2params($ini_settings); if ($file_cache !== null) { - $ini_settings['opcache.file_cache'] = '/tmp'; + $ini_settings['opcache.file_cache'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-run-tests-file-cache'; + if ($file_cache === 'prime') { + rmdir_recursive($ini_settings['opcache.file_cache']); + mkdir($ini_settings['opcache.file_cache'], recursive: true); + } // Make sure warnings still show up on the second run. $ini_settings['opcache.record_warnings'] = '1'; // File cache is currently incompatible with JIT.

« previous php.cvs (#140081) next »