diff options
author | Peter Kokot <peterkokot@gmail.com> | 2019-07-21 00:49:35 +0200 |
---|---|---|
committer | Peter Kokot <peterkokot@gmail.com> | 2019-07-21 00:49:35 +0200 |
commit | b1643e166d039057cdefb9a5a5420d165f2b2e05 (patch) | |
tree | 8dbf9d1ddce4c4053687cc9607e5a303b0b3d633 | |
parent | f5227c5863a79cb219902f32aaebacac77a6e133 (diff) | |
download | php-git-b1643e166d039057cdefb9a5a5420d165f2b2e05.tar.gz |
Fix failed tests for phar
- when $status is boolean, E_NOTICE appears and tests fail
- opcache is never enabled on these tests anyway.
- Add opcache.revalidate_freq=0 to testing script
Instead of checking this in the tests files it can be used directly in
the main testing script. Also this fixes failed tests.
- Use opcache_invalidate() instead of sleep() delay in some tests. Some
delays are still used since the opcache_invalidate seems to be buggy
and not working as expected.
Closes GH-4392
-rw-r--r-- | ext/phar/tests/create_new_and_modify.phpt | 12 | ||||
-rw-r--r-- | ext/phar/tests/delete_in_phar.phpt | 9 | ||||
-rw-r--r-- | ext/phar/tests/delete_in_phar_confirm.phpt | 8 | ||||
-rw-r--r-- | ext/phar/tests/tar/create_new_and_modify.phpt | 12 | ||||
-rw-r--r-- | ext/phar/tests/tar/delete_in_phar.phpt | 8 | ||||
-rw-r--r-- | ext/phar/tests/tar/delete_in_phar_confirm.phpt | 8 | ||||
-rw-r--r-- | ext/phar/tests/zip/create_new_and_modify.phpt | 12 | ||||
-rw-r--r-- | ext/phar/tests/zip/delete_in_phar.phpt | 9 | ||||
-rw-r--r-- | ext/phar/tests/zip/delete_in_phar_confirm.phpt | 8 | ||||
-rwxr-xr-x | run-tests.php | 1 |
10 files changed, 22 insertions, 65 deletions
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt index f363eb8ba3..5aa840e383 100644 --- a/ext/phar/tests/create_new_and_modify.phpt +++ b/ext/phar/tests/create_new_and_modify.phpt @@ -21,11 +21,13 @@ $sig1 = $phar->getSignature(); include $pname . '/a.php'; if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } + $status = opcache_get_status(); + if (is_array($status) && ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"]))) { + opcache_invalidate($pname . '/a.php', true); + // opcache_invalidate is buggy and doesn't work as expected so we add a + // minor delay here. + sleep(2); + } } file_put_contents($pname .'/a.php', "modified!\n"); diff --git a/ext/phar/tests/delete_in_phar.phpt b/ext/phar/tests/delete_in_phar.phpt index 6644030936..0d904d57bb 100644 --- a/ext/phar/tests/delete_in_phar.phpt +++ b/ext/phar/tests/delete_in_phar.phpt @@ -16,14 +16,6 @@ $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include 'files/phar_test.inc'; include $pname . '/a.php'; @@ -54,4 +46,3 @@ Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d ===DONE=== - diff --git a/ext/phar/tests/delete_in_phar_confirm.phpt b/ext/phar/tests/delete_in_phar_confirm.phpt index 2596e06462..1f8015f0cb 100644 --- a/ext/phar/tests/delete_in_phar_confirm.phpt +++ b/ext/phar/tests/delete_in_phar_confirm.phpt @@ -16,14 +16,6 @@ $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include 'files/phar_test.inc'; include $pname . '/a.php'; diff --git a/ext/phar/tests/tar/create_new_and_modify.phpt b/ext/phar/tests/tar/create_new_and_modify.phpt index cccc57d8f5..d0a954a981 100644 --- a/ext/phar/tests/tar/create_new_and_modify.phpt +++ b/ext/phar/tests/tar/create_new_and_modify.phpt @@ -15,11 +15,13 @@ $pname = 'phar://' . $fname; file_put_contents($pname . '/a.php', "brand new!\n"); if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } + $status = opcache_get_status(); + if (is_array($status) && ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"]))) { + opcache_invalidate($pname . '/a.php', true); + // opcache_invalidate is buggy and doesn't work as expected so we add a + // minor delay here. + sleep(2); + } } $phar = new Phar($fname); diff --git a/ext/phar/tests/tar/delete_in_phar.phpt b/ext/phar/tests/tar/delete_in_phar.phpt index 871f2fe6f4..0b4362aa91 100644 --- a/ext/phar/tests/tar/delete_in_phar.phpt +++ b/ext/phar/tests/tar/delete_in_phar.phpt @@ -18,14 +18,6 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; $phar->setStub('<?php __HALT_COMPILER(); ?>'); $phar->stopBuffering(); -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include $alias . '/a.php'; include $alias . '/b.php'; include $alias . '/b/c.php'; diff --git a/ext/phar/tests/tar/delete_in_phar_confirm.phpt b/ext/phar/tests/tar/delete_in_phar_confirm.phpt index b66656b8c1..ec4eec68b1 100644 --- a/ext/phar/tests/tar/delete_in_phar_confirm.phpt +++ b/ext/phar/tests/tar/delete_in_phar_confirm.phpt @@ -18,14 +18,6 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; $phar->setStub('<?php __HALT_COMPILER(); ?>'); $phar->stopBuffering(); -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include $alias . '/a.php'; include $alias . '/b.php'; include $alias . '/b/c.php'; diff --git a/ext/phar/tests/zip/create_new_and_modify.phpt b/ext/phar/tests/zip/create_new_and_modify.phpt index 302355794e..2a52e8a5ca 100644 --- a/ext/phar/tests/zip/create_new_and_modify.phpt +++ b/ext/phar/tests/zip/create_new_and_modify.phpt @@ -15,11 +15,13 @@ $pname = 'phar://' . $fname; file_put_contents($pname . '/a.php', "brand new!\n"); if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } + $status = opcache_get_status(); + if (is_array($status) && ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"]))) { + opcache_invalidate($pname . '/a.php', true); + // opcache_invalidate is buggy and doesn't work as expected so we add a + // minor delay here. + sleep(2); + } } $phar = new Phar($fname); diff --git a/ext/phar/tests/zip/delete_in_phar.phpt b/ext/phar/tests/zip/delete_in_phar.phpt index 5c83202509..86a6d4dbd4 100644 --- a/ext/phar/tests/zip/delete_in_phar.phpt +++ b/ext/phar/tests/zip/delete_in_phar.phpt @@ -18,14 +18,6 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; $phar->setStub('<?php __HALT_COMPILER(); ?>'); $phar->stopBuffering(); -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include $alias . '/a.php'; include $alias . '/b.php'; include $alias . '/b/c.php'; @@ -54,4 +46,3 @@ Warning: include(%sdelete_in_phar.phar.zip/b/c.php): failed to open stream: phar Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d ===DONE=== - diff --git a/ext/phar/tests/zip/delete_in_phar_confirm.phpt b/ext/phar/tests/zip/delete_in_phar_confirm.phpt index 262dabdbb3..26ff9b3456 100644 --- a/ext/phar/tests/zip/delete_in_phar_confirm.phpt +++ b/ext/phar/tests/zip/delete_in_phar_confirm.phpt @@ -18,14 +18,6 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; $phar->setStub('<?php __HALT_COMPILER(); ?>'); $phar->stopBuffering(); -if (function_exists("opcache_get_status")) { - $status = opcache_get_status(); - if ($status["opcache_enabled"]) { - ini_set("opcache.revalidate_freq", "0"); - sleep(2); - } -} - include $alias . '/a.php'; include $alias . '/b.php'; include $alias . '/b/c.php'; diff --git a/run-tests.php b/run-tests.php index 84dccd7380..2c11961a05 100755 --- a/run-tests.php +++ b/run-tests.php @@ -258,6 +258,7 @@ NO_PROC_OPEN_ERROR; 'log_errors_max_len=0', 'opcache.fast_shutdown=0', 'opcache.file_update_protection=0', + 'opcache.revalidate_freq=0', 'zend.assertions=1', ); |