Skip to content

Commit

Permalink
Fix brittle test
Browse files Browse the repository at this point in the history
This test is easily tripped by former test runs with other PHP
versions.  To avoid such false positives, we check that there is at
least one respective OPcache file, and that all found OPcache user ID
folders have exactly 32 hexadecimal digits.
  • Loading branch information
cmb69 committed Jul 1, 2019
1 parent a149f9f commit be559e6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ext/opcache/tests/bug78189.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ opcache.file_cache_only=1
<?php
$tmpdir = sys_get_temp_dir();
$pattern = $tmpdir . '/*/*/' . str_replace(':', '', __DIR__) . '/bug78189.php.bin';
foreach (glob($pattern) as $filename) {
var_dump(preg_match('~/[0-9a-f]{32}/~', substr($filename, strlen($tmpdir), 34)));
$filenames = glob($pattern);
if (count($filenames)) {
foreach ($filenames as $filename) {
$part = substr($filename, strlen($tmpdir), 34);
if (!preg_match('~/[0-9a-f]{32}/~', $part)) {
echo "invalid opcache folder: $part\n";
}
}
} else {
echo "no opcache file found!\n";
}
?>
--EXPECT--
int(1)

0 comments on commit be559e6

Please sign in to comment.