Skip to content

Commit 314bdc6

Browse files
committed
Emit warning when OPCache is enabled while collecting coverage
1 parent 11e5eca commit 314bdc6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/php-code-coverage/issues/1022
3+
--INI--
4+
opcache.enable_cli=1
5+
--SKIPIF--
6+
<?php declare(strict_types=1);
7+
require __DIR__ . '/../../_files/skip-if-requires-code-coverage-driver.php';
8+
9+
if (!function_exists('opcache_compile_file')) {
10+
echo 'skip, opcache extension is not loaded';
11+
} elseif (ini_get('opcache.enable_cli') !== '1') {
12+
echo 'skip, opcache not enabled for CLI';
13+
}
14+
--FILE--
15+
<?php declare(strict_types=1);
16+
$_SERVER['argv'][] = '--do-not-cache-result';
17+
$_SERVER['argv'][] = '--no-configuration';
18+
$_SERVER['argv'][] = '--bootstrap';
19+
$_SERVER['argv'][] = __DIR__ . '/ignore-class-using-attribute/src/CoveredClass.php';
20+
$_SERVER['argv'][] = '--coverage-filter';
21+
$_SERVER['argv'][] = __DIR__ . '/ignore-class-using-attribute/src';
22+
$_SERVER['argv'][] = '--coverage-text';
23+
$_SERVER['argv'][] = __DIR__ . '/ignore-class-using-attribute/tests';
24+
25+
require_once __DIR__ . '/../../bootstrap.php';
26+
27+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
28+
--EXPECTF--
29+
PHPUnit %s by Sebastian Bergmann and contributors.
30+
31+
Runtime: %s
32+
33+
. 1 / 1 (100%)
34+
35+
Time: %s, Memory: %s MB
36+
37+
There was 1 PHPUnit test runner warning:
38+
39+
1) Code coverage might produce unreliable results when OPCache is enabled.
40+
41+
OK, but there were issues!
42+
Tests: 1, Assertions: 1, PHPUnit Warnings: 1.
43+
%A

0 commit comments

Comments
 (0)