Skip to content

Commit

Permalink
Remove CodeCoverageAnnotationIgnorer (#1517)
Browse files Browse the repository at this point in the history
Since we have a very explicit annotation `@infection-ignore-all` (added in #1468) that, again, very explicit on the purpose, and works not only for methods, but for most kinds of statements, let's remove `@codeCoverageIgnore` ignorer, that not only implicit (you may only want to ignore a piece of code temporarily, and only ignore) but also messes up the metrics (hides otherwise-uncovered mutations).
  • Loading branch information
sanmai committed May 4, 2021
1 parent e60c464 commit bf27a84
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 240 deletions.

This file was deleted.

9 changes: 1 addition & 8 deletions src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php
Expand Up @@ -38,13 +38,11 @@
use function escapeshellarg;
use Infection\AbstractTestFramework\MemoryUsageAware;
use Infection\Config\ValueProvider\PCOVDirectoryProvider;
use Infection\PhpParser\Visitor\IgnoreNode\PhpUnitCodeCoverageAnnotationIgnorer;
use Infection\TestFramework\AbstractTestFrameworkAdapter;
use Infection\TestFramework\CommandLineArgumentsAndOptionsBuilder;
use Infection\TestFramework\CommandLineBuilder;
use Infection\TestFramework\Config\InitialConfigBuilder;
use Infection\TestFramework\Config\MutationConfigBuilder;
use Infection\TestFramework\IgnoresAdditionalNodes;
use Infection\TestFramework\ProvidesInitialRunOnlyOptions;
use Infection\TestFramework\VersionParser;
use function Safe\preg_match;
Expand All @@ -56,7 +54,7 @@
* @internal
* @final
*/
class PhpUnitAdapter extends AbstractTestFrameworkAdapter implements IgnoresAdditionalNodes, MemoryUsageAware, ProvidesInitialRunOnlyOptions
class PhpUnitAdapter extends AbstractTestFrameworkAdapter implements MemoryUsageAware, ProvidesInitialRunOnlyOptions
{
public const COVERAGE_DIR = 'coverage-xml';

Expand Down Expand Up @@ -172,11 +170,6 @@ public function getInitialTestsFailRecommendations(string $commandLine): string
return $recommendations;
}

public function getNodeIgnorers(): array
{
return [new PhpUnitCodeCoverageAnnotationIgnorer()];
}

/**
* @return string[]
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/Ignore_All_Mutations/src/DoNotMutateClass.php
@@ -0,0 +1,12 @@
<?php

namespace Ignore_All_Mutations;

/** @infection-ignore-all */
class DoNotMutateClass
{
public function divide(int $a, int $b): float
{
return $a / $b;
}
}
16 changes: 16 additions & 0 deletions tests/e2e/Ignore_All_Mutations/tests/DoNotMutateClassTest.php
@@ -0,0 +1,16 @@
<?php

namespace Ignore_All_Mutations\Test;

use Ignore_All_Mutations\DoNotMutateClass;
use PHPUnit\Framework\TestCase;

class DoNotMutateClassTest extends TestCase
{
public function test_divide()
{
$sourceClass = new DoNotMutateClass();
$this->assertGreaterThan(0.0, $sourceClass->divide(2, 2));
}

}

This file was deleted.

12 changes: 0 additions & 12 deletions tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php
Expand Up @@ -35,10 +35,8 @@

namespace Infection\Tests\TestFramework\PhpUnit\Adapter;

use function array_map;
use const DIRECTORY_SEPARATOR;
use Infection\Config\ValueProvider\PCOVDirectoryProvider;
use Infection\PhpParser\Visitor\IgnoreNode\PhpUnitCodeCoverageAnnotationIgnorer;
use Infection\TestFramework\CommandLineArgumentsAndOptionsBuilder;
use Infection\TestFramework\CommandLineBuilder;
use Infection\TestFramework\PhpUnit\Adapter\PhpUnitAdapter;
Expand Down Expand Up @@ -124,16 +122,6 @@ public function test_it_provides_initial_run_only_options(): void
);
}

public function test_it_provides_node_ignorers(): void
{
$nodeIgnorers = array_map('get_class', $this->adapter->getNodeIgnorers());

$this->assertSame(
[PhpUnitCodeCoverageAnnotationIgnorer::class],
$nodeIgnorers
);
}

/**
* @group integration
*/
Expand Down

0 comments on commit bf27a84

Please sign in to comment.