Skip to content

Commit df2319f

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

File tree

1 file changed

+42
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)