From fafddf41931234f617531c0212572230dc4f7522 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Tue, 4 May 2021 10:20:30 +0900 Subject: [PATCH 1/3] Remove CodeCoverageAnnotationIgnorer Ref #1468 --- .../PhpUnitCodeCoverageAnnotationIgnorer.php | 59 ------- .../PhpUnit/Adapter/PhpUnitAdapter.php | 9 +- ...pUnitCodeCoverageAnnotationIgnorerTest.php | 161 ------------------ .../PhpUnit/Adapter/PhpUnitAdapterTest.php | 10 -- 4 files changed, 1 insertion(+), 238 deletions(-) delete mode 100644 src/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorer.php delete mode 100644 tests/phpunit/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorerTest.php diff --git a/src/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorer.php b/src/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorer.php deleted file mode 100644 index 85d0978cc..000000000 --- a/src/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorer.php +++ /dev/null @@ -1,59 +0,0 @@ -getDocComment(); - - return $docComment !== null - && strpos($docComment->getText(), '@codeCoverageIgnore') !== false - ; - } -} diff --git a/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php b/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php index 13b6cc69f..03326c597 100644 --- a/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php +++ b/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php @@ -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; @@ -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'; @@ -172,11 +170,6 @@ public function getInitialTestsFailRecommendations(string $commandLine): string return $recommendations; } - public function getNodeIgnorers(): array - { - return [new PhpUnitCodeCoverageAnnotationIgnorer()]; - } - /** * @return string[] */ diff --git a/tests/phpunit/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorerTest.php b/tests/phpunit/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorerTest.php deleted file mode 100644 index cb7c66c2d..000000000 --- a/tests/phpunit/PhpParser/Visitor/IgnoreNode/PhpUnitCodeCoverageAnnotationIgnorerTest.php +++ /dev/null @@ -1,161 +0,0 @@ -createSpy(); - - $this->parseAndTraverse($code, $spy); - - $this->assertSame($count, $spy->nodeCounter); - } - - public function provideIgnoreCases(): iterable - { - yield 'classes with annotation are ignored' => [ - <<<'PHP' - [ - <<<'PHP' - [ - <<<'PHP' - [ - <<<'PHP' - [ - <<<'PHP' -adapter->getNodeIgnorers()); - - $this->assertSame( - [PhpUnitCodeCoverageAnnotationIgnorer::class], - $nodeIgnorers - ); - } - /** * @group integration */ From f7515aef4b48ee055e47fce8644c3f5620b814c4 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Tue, 4 May 2021 10:29:57 +0900 Subject: [PATCH 2/3] cs --- .../TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php b/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php index 6b6999cc8..212fdc7ba 100644 --- a/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php +++ b/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php @@ -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; From 3c3fb47cc5db7169a7f238d346d91626b46a51c1 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Tue, 4 May 2021 10:36:02 +0900 Subject: [PATCH 3/3] Ensure we ignore stuff on class level too Without annotation: 4 mutations were generated: 3 mutants were killed 0 mutants were not covered by tests 1 covered mutants were not detected With annotation: 2 mutations were generated: 2 mutants were killed 0 mutants were not covered by tests 0 covered mutants were not detected --- .../src/DoNotMutateClass.php | 12 ++++++++++++ .../tests/DoNotMutateClassTest.php | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/e2e/Ignore_All_Mutations/src/DoNotMutateClass.php create mode 100644 tests/e2e/Ignore_All_Mutations/tests/DoNotMutateClassTest.php diff --git a/tests/e2e/Ignore_All_Mutations/src/DoNotMutateClass.php b/tests/e2e/Ignore_All_Mutations/src/DoNotMutateClass.php new file mode 100644 index 000000000..917716edb --- /dev/null +++ b/tests/e2e/Ignore_All_Mutations/src/DoNotMutateClass.php @@ -0,0 +1,12 @@ +assertGreaterThan(0.0, $sourceClass->divide(2, 2)); + } + +}