Skip to content

Commit 316be7f

Browse files
committed
Emit: "Code coverage might produce unreliable results when OPCache is enabled"
1 parent 45ffb60 commit 316be7f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Runner/CodeCoverage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
use function assert;
1313
use function file_put_contents;
14+
use function function_exists;
15+
use function ini_get;
1416
use function sprintf;
1517
use function sys_get_temp_dir;
1618
use PHPUnit\Event\Facade as EventFacade;
@@ -124,6 +126,16 @@ public function init(Configuration $configuration, CodeCoverageFilterRegistry $c
124126
$this->codeCoverage()->excludeUncoveredFiles();
125127
}
126128

129+
if (
130+
// opcache is built-in since 8.5
131+
function_exists('opcache_compile_file') &&
132+
ini_get('opcache.enable_cli') === '1'
133+
) {
134+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
135+
'Code coverage might produce unreliable results when OPCache is enabled.',
136+
);
137+
}
138+
127139
if ($codeCoverageFilterRegistry->get()->isEmpty()) {
128140
if (!$codeCoverageFilterRegistry->configured()) {
129141
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(

0 commit comments

Comments
 (0)