Skip to content

Commit

Permalink
Ignore mutations by regex for uncovered mutants (#1585)
Browse files Browse the repository at this point in the history
Fixes #1561
  • Loading branch information
maks-rafalko committed Oct 2, 2021
1 parent c3e23df commit f7a1af2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Process/Runner/MutationTestingRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,6 @@ public function run(iterable $mutations, string $testFrameworkExtraOptions): voi
->cast(function (Mutation $mutation): Mutant {
return $this->mutantFactory->create($mutation);
})
->filter(function (Mutant $mutant) {
// It's a proxy call to Mutation, can be done one stage up
if ($mutant->isCoveredByTest()) {
return true;
}

$this->eventDispatcher->dispatch(new MutantProcessWasFinished(
MutantExecutionResult::createFromNonCoveredMutant($mutant)
));

return false;
})
->filter(function (Mutant $mutant) {
$mutatorName = $mutant->getMutation()->getMutatorName();

Expand All @@ -131,6 +119,18 @@ public function run(iterable $mutations, string $testFrameworkExtraOptions): voi

return true;
})
->filter(function (Mutant $mutant) {
// It's a proxy call to Mutation, can be done one stage up
if ($mutant->isCoveredByTest()) {
return true;
}

$this->eventDispatcher->dispatch(new MutantProcessWasFinished(
MutantExecutionResult::createFromNonCoveredMutant($mutant)
));

return false;
})
->filter(function (Mutant $mutant) {
// TODO refactor this comparison into a dedicated comparer to make it possible to swap strategies
if ($mutant->getMutation()->getNominalTestExecutionTime() < $this->timeout) {
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/Exclude_Mutations_By_Regex/src/SourceClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public function hello(): string
{
Assert::numeric('1');

// @codeCoverageIgnoreStart
$this->getString();
// @codeCoverageIgnoreEnd

return 'hello';
}
Expand Down

0 comments on commit f7a1af2

Please sign in to comment.