mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 10:47:25 +01:00
Improves coverage feedback
This commit is contained in:
@ -75,7 +75,7 @@
|
|||||||
"lint": "pint --test",
|
"lint": "pint --test",
|
||||||
"test:lint": "pint --test",
|
"test:lint": "pint --test",
|
||||||
"test:types": "phpstan analyse --ansi --memory-limit=-1 --debug",
|
"test:types": "phpstan analyse --ansi --memory-limit=-1 --debug",
|
||||||
"test:unit": "php bin/pest --colors=always --exclude-group=integration",
|
"test:unit": "php bin/pest --colors=always --exclude-group=integration --compact",
|
||||||
"test:parallel": "exit 1",
|
"test:parallel": "exit 1",
|
||||||
"test:integration": "php bin/pest --colors=always --group=integration -v",
|
"test:integration": "php bin/pest --colors=always --group=integration -v",
|
||||||
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
|
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
|
||||||
|
|||||||
@ -87,6 +87,24 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
$this->coverageMin = (float) $minOption;
|
$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;
|
return $originals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,21 @@ final class Coverage
|
|||||||
*/
|
*/
|
||||||
public static function isAvailable(): bool
|
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