Skip to content

Commit 387a3af

Browse files
authored
Fix run-tests.php --file-cache-prime with multiple workers (GH-22886)
* 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. * Move opcache.opt_debug_level tests These need to live in ext/opcache/tests to be skipped by run-tests.php for the --file-cache-use tests, which won't compile the files and thus won't dump the output. * Mark preloading test as opcache.file_cache_only=0 Preloading requires shm.
1 parent bf46492 commit 387a3af

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

Zend/tests/partial_application/preloading.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PFA preloading
44
opcache.enable=1
55
opcache.enable_cli=1
66
opcache.preload={PWD}/preloading.inc
7+
opcache.file_cache_only=0
78
--SKIPIF--
89
<?php
910
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');

ext/standard/tests/array/array_map_foreach_optimization_006.phpt renamed to ext/opcache/tests/array_map_foreach_optimization_007.phpt

File renamed without changes.

ext/standard/tests/array/array_map_foreach_optimization_007.phpt renamed to ext/opcache/tests/array_map_foreach_optimization_008.phpt

File renamed without changes.

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)