mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: adds --compact to coverage
This commit is contained in:
@ -37,6 +37,11 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public bool $coverage = false;
|
public bool $coverage = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether it should show the coverage or not.
|
||||||
|
*/
|
||||||
|
public bool $compact = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum coverage.
|
* The minimum coverage.
|
||||||
*/
|
*/
|
||||||
@ -124,6 +129,10 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
$this->coverageExactly = (float) $exactlyOption;
|
$this->coverageExactly = (float) $exactlyOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['COLLISION_PRINTER_COMPACT'] ?? false) {
|
||||||
|
$this->compact = true;
|
||||||
|
}
|
||||||
|
|
||||||
return $originals;
|
return $originals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +153,7 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$coverage = \Pest\Support\Coverage::report($this->output);
|
$coverage = \Pest\Support\Coverage::report($this->output, $this->compact);
|
||||||
$exitCode = (int) ($coverage < $this->coverageMin);
|
$exitCode = (int) ($coverage < $this->coverageMin);
|
||||||
|
|
||||||
if ($exitCode === 0 && $this->coverageExactly !== null) {
|
if ($exitCode === 0 && $this->coverageExactly !== null) {
|
||||||
|
|||||||
@ -74,7 +74,7 @@ final class Coverage
|
|||||||
* Reports the code coverage report to the
|
* Reports the code coverage report to the
|
||||||
* console and returns the result in float.
|
* console and returns the result in float.
|
||||||
*/
|
*/
|
||||||
public static function report(OutputInterface $output): float
|
public static function report(OutputInterface $output, bool $compact = false): float
|
||||||
{
|
{
|
||||||
if (! file_exists($reportPath = self::getPath())) {
|
if (! file_exists($reportPath = self::getPath())) {
|
||||||
if (self::usingXdebug()) {
|
if (self::usingXdebug()) {
|
||||||
@ -113,6 +113,10 @@ final class Coverage
|
|||||||
? '100.0'
|
? '100.0'
|
||||||
: number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', '');
|
: number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', '');
|
||||||
|
|
||||||
|
if ($percentage === '100.0' && $compact) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$uncoveredLines = '';
|
$uncoveredLines = '';
|
||||||
|
|
||||||
$percentageOfExecutedLinesAsString = $file->percentageOfExecutedLines()->asString();
|
$percentageOfExecutedLinesAsString = $file->percentageOfExecutedLines()->asString();
|
||||||
|
|||||||
Reference in New Issue
Block a user