Skip to content

Commit dba4d83

Browse files
committed
Fix run-tests.php --file-cache-prime with multiple workers
We want to remove the directory only before running tests, rather than for every test. That causes races, but also defeats the purpose of priming the cache.
1 parent b70e95d commit dba4d83

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

run-tests.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,12 @@ function main(): void
700700
verify_config($php);
701701
write_information($user_tests, $phpdbg);
702702

703+
if ($file_cache === 'prime') {
704+
$cache_dir = get_file_cache_dir();
705+
rmdir_recursive($cache_dir);
706+
mkdir($cache_dir, recursive: true);
707+
}
708+
703709
if ($test_cnt) {
704710
$exts_tested = [];
705711
$exts_skipped = [];
@@ -1054,6 +1060,11 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false)
10541060
closedir($o);
10551061
}
10561062

1063+
function get_file_cache_dir(): string
1064+
{
1065+
return sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-run-tests-file-cache';
1066+
}
1067+
10571068
function rmdir_recursive($dir)
10581069
{
10591070
if (!file_exists($dir)) {
@@ -2091,11 +2102,7 @@ function run_test(string $php, $file, array $env): string
20912102
$orig_ini_settings = settings2params($ini_settings);
20922103

20932104
if ($file_cache !== null) {
2094-
$ini_settings['opcache.file_cache'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-run-tests-file-cache';
2095-
if ($file_cache === 'prime') {
2096-
rmdir_recursive($ini_settings['opcache.file_cache']);
2097-
mkdir($ini_settings['opcache.file_cache'], recursive: true);
2098-
}
2105+
$ini_settings['opcache.file_cache'] = get_file_cache_dir();
20992106
// Make sure warnings still show up on the second run.
21002107
$ini_settings['opcache.record_warnings'] = '1';
21012108
// File cache is currently incompatible with JIT.

0 commit comments

Comments
 (0)