Skip to content

Commit 3edc2b7

Browse files
committed
Fix GH-17770 test file_cache path handling on Windows
1 parent 5771faf commit 3edc2b7

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

ext/opcache/tests/gh17770_jit_file_cache_write.phpt

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--TEST--
22
GH-17770: opcache.file_cache writes with JIT enabled
3+
--SKIPIF--
4+
<?php
5+
@mkdir(__DIR__ . '/gh17770_cache', 0777, true);
6+
if (ini_get('opcache.jit') === false) {
7+
die('skip JIT is not supported');
8+
}
9+
?>
310
--EXTENSIONS--
411
opcache
512
--INI--
613
opcache.enable=1
714
opcache.enable_cli=1
815
opcache.jit=tracing
916
opcache.jit_buffer_size=16M
10-
opcache.file_cache={TMP}/gh17770-opcache-file-cache
17+
opcache.file_cache="{PWD}/gh17770_cache"
1118
opcache.file_cache_consistency_checks=0
12-
--SKIPIF--
13-
<?php
14-
if (!@mkdir(sys_get_temp_dir() . '/gh17770-opcache-file-cache', 0777, true) && !is_dir(sys_get_temp_dir() . '/gh17770-opcache-file-cache')) {
15-
die('skip unable to create file cache directory');
16-
}
17-
if (ini_get('opcache.jit') === false) {
18-
die('skip JIT is not supported');
19-
}
20-
?>
2119
--FILE--
2220
<?php
2321
function removeDirRecursive(string $dir): void {
@@ -45,22 +43,13 @@ $cacheDir = ini_get('opcache.file_cache');
4543
removeDirRecursive($cacheDir);
4644
@mkdir($cacheDir, 0777, true);
4745

48-
$tmpPhpFile = dirname($cacheDir) . '/gh17770-opcache-target.php';
46+
$tmpPhpFile = __DIR__ . '/gh17770-opcache-target.php';
4947
file_put_contents($tmpPhpFile, "<?php\nfunction gh17770() { return 42; }\ngh17770();\n");
5048

5149
@opcache_reset();
5250
opcache_compile_file($tmpPhpFile);
5351

54-
$hasCacheFile = false;
55-
$iterator = new RecursiveIteratorIterator(
56-
new RecursiveDirectoryIterator($cacheDir, RecursiveDirectoryIterator::SKIP_DOTS)
57-
);
58-
foreach ($iterator as $entry) {
59-
if ($entry->isFile()) {
60-
$hasCacheFile = true;
61-
break;
62-
}
63-
}
52+
$hasCacheFile = opcache_is_script_cached_in_file_cache($tmpPhpFile);
6453

6554
echo $hasCacheFile ? "OK\n" : "FAIL: opcache file cache is empty\n";
6655
?>
@@ -87,9 +76,8 @@ function removeDirRecursive(string $dir): void {
8776
@rmdir($dir);
8877
}
8978

90-
$cacheDir = ini_get('opcache.file_cache');
91-
removeDirRecursive($cacheDir);
92-
@unlink(dirname($cacheDir) . '/gh17770-opcache-target.php');
79+
removeDirRecursive(__DIR__ . '/gh17770_cache');
80+
@unlink(__DIR__ . '/gh17770-opcache-target.php');
9381
?>
9482
--EXPECT--
9583
OK

0 commit comments

Comments
 (0)