mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Revert "Merge pull request #919 from WendellAdriel/feature/coverage-errors-only-flag-2"
This reverts commit1e2ca40c5b, reversing changes made to4522cb5dcb.
This commit is contained in:
@ -27,20 +27,6 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private const MIN_OPTION = 'min';
|
private const MIN_OPTION = 'min';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private const ERRORS_ONLY_OPTION = 'errors-only';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
private const ALLOWED_OPTIONS = [
|
|
||||||
self::COVERAGE_OPTION,
|
|
||||||
self::MIN_OPTION,
|
|
||||||
self::ERRORS_ONLY_OPTION,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether it should show the coverage or not.
|
* Whether it should show the coverage or not.
|
||||||
*/
|
*/
|
||||||
@ -51,11 +37,6 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public float $coverageMin = 0.0;
|
public float $coverageMin = 0.0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether it should show only errors or not.
|
|
||||||
*/
|
|
||||||
public bool $errorsOnly = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Plugin instance.
|
* Creates a new Plugin instance.
|
||||||
*/
|
*/
|
||||||
@ -70,7 +51,7 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
public function handleArguments(array $originals): array
|
public function handleArguments(array $originals): array
|
||||||
{
|
{
|
||||||
$arguments = [...[''], ...array_values(array_filter($originals, function (string $original): bool {
|
$arguments = [...[''], ...array_values(array_filter($originals, function (string $original): bool {
|
||||||
foreach (self::ALLOWED_OPTIONS as $option) {
|
foreach ([self::COVERAGE_OPTION, self::MIN_OPTION] as $option) {
|
||||||
if ($original === sprintf('--%s', $option)) {
|
if ($original === sprintf('--%s', $option)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -92,7 +73,6 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
$inputs = [];
|
$inputs = [];
|
||||||
$inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE);
|
$inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE);
|
||||||
$inputs[] = new InputOption(self::MIN_OPTION, null, InputOption::VALUE_REQUIRED);
|
$inputs[] = new InputOption(self::MIN_OPTION, null, InputOption::VALUE_REQUIRED);
|
||||||
$inputs[] = new InputOption(self::ERRORS_ONLY_OPTION, null, InputOption::VALUE_NONE);
|
|
||||||
|
|
||||||
$input = new ArgvInput($arguments, new InputDefinition($inputs));
|
$input = new ArgvInput($arguments, new InputDefinition($inputs));
|
||||||
if ((bool) $input->getOption(self::COVERAGE_OPTION)) {
|
if ((bool) $input->getOption(self::COVERAGE_OPTION)) {
|
||||||
@ -126,10 +106,6 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
$this->coverageMin = (float) $minOption;
|
$this->coverageMin = (float) $minOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bool) $input->getOption(self::ERRORS_ONLY_OPTION)) {
|
|
||||||
$this->errorsOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $originals;
|
return $originals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +122,7 @@ final class Coverage implements AddsOutput, HandlesArguments
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$coverage = \Pest\Support\Coverage::report($this->output, $this->coverageMin, $this->errorsOnly);
|
$coverage = \Pest\Support\Coverage::report($this->output);
|
||||||
|
|
||||||
$exitCode = (int) ($coverage < $this->coverageMin);
|
$exitCode = (int) ($coverage < $this->coverageMin);
|
||||||
|
|
||||||
|
|||||||
@ -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 $coverageMin, bool $showErrorsOnly): float
|
public static function report(OutputInterface $output): float
|
||||||
{
|
{
|
||||||
if (! file_exists($reportPath = self::getPath())) {
|
if (! file_exists($reportPath = self::getPath())) {
|
||||||
if (self::usingXdebug()) {
|
if (self::usingXdebug()) {
|
||||||
@ -126,10 +126,6 @@ final class Coverage
|
|||||||
|
|
||||||
$truncateAt = max(1, terminal()->width() - 12);
|
$truncateAt = max(1, terminal()->width() - 12);
|
||||||
|
|
||||||
if ($showErrorsOnly && (float) $percentage >= $coverageMin) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderUsing($output);
|
renderUsing($output);
|
||||||
render(<<<HTML
|
render(<<<HTML
|
||||||
<div class="flex mx-2">
|
<div class="flex mx-2">
|
||||||
|
|||||||
@ -34,18 +34,6 @@ it('adds coverage if --min exist', function () {
|
|||||||
expect($plugin->coverageMin)->toEqual(2.4);
|
expect($plugin->coverageMin)->toEqual(2.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds coverage if --errors-only exist', function () {
|
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
|
||||||
expect($plugin->errorsOnly)->toBeFalse()
|
|
||||||
->and($plugin->coverage)->toBeFalse();
|
|
||||||
|
|
||||||
$plugin->handleArguments([]);
|
|
||||||
expect($plugin->errorsOnly)->toBeFalse();
|
|
||||||
|
|
||||||
$plugin->handleArguments(['--errors-only']);
|
|
||||||
expect($plugin->errorsOnly)->toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('generates coverage based on file input', function () {
|
it('generates coverage based on file input', function () {
|
||||||
expect(Coverage::getMissingCoverage(new class()
|
expect(Coverage::getMissingCoverage(new class()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user