mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
Improves coverage feedback
This commit is contained in:
@ -87,6 +87,24 @@ final class Coverage implements AddsOutput, HandlesArguments
|
||||
$this->coverageMin = (float) $minOption;
|
||||
}
|
||||
|
||||
if (! \Pest\Support\Coverage::isAvailable()) {
|
||||
if (\Pest\Support\Coverage::usingXdebug()) {
|
||||
$this->output->writeln([
|
||||
'',
|
||||
" <fg=default;bg=red;options=bold> ERROR </> Unable to get coverage using Xdebug. Did you set <href=https://xdebug.org/docs/code_coverage#mode>Xdebug's coverage mode</>?</>",
|
||||
'',
|
||||
]);
|
||||
} else {
|
||||
$this->output->writeln([
|
||||
'',
|
||||
' <fg=default;bg=red;options=bold> ERROR </> No code coverage driver is available.</>',
|
||||
'',
|
||||
]);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $originals;
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,21 @@ final class Coverage
|
||||
*/
|
||||
public static function isAvailable(): bool
|
||||
{
|
||||
return (new Runtime())->canCollectCodeCoverage();
|
||||
$runtime = new Runtime();
|
||||
|
||||
if (! $runtime->canCollectCodeCoverage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($runtime->hasXdebug()) {
|
||||
if (version_compare((string) phpversion('xdebug'), '3.1', '>=')) {
|
||||
if (! in_array('coverage', xdebug_info('mode'), true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user