From 4d3f9de673b00fd25ccd1236ccb7d4876f60245f Mon Sep 17 00:00:00 2001 From: Oleg Zhulnev Date: Sun, 12 Dec 2021 22:16:24 +0300 Subject: [PATCH 1/3] Show ignored mutants count in metrics and logs --- infection.json | 7 +- src/Console/OutputFormatter/DotFormatter.php | 7 +- .../OutputFormatterStyleConfigurator.php | 11 +- ...MutationTestingConsoleLoggerSubscriber.php | 1 + src/Logger/DebugFileLogger.php | 5 + src/Logger/JsonLogger.php | 4 +- src/Logger/PerMutatorLogger.php | 3 +- src/Logger/SummaryFileLogger.php | 1 + src/Metrics/MetricsCalculator.php | 7 +- src/Metrics/ResultsCollector.php | 10 +- .../TargetDetectionStatusesProvider.php | 4 + src/Mutant/DetectionStatus.php | 2 + src/Mutant/MutantExecutionResult.php | 5 + src/Process/Runner/MutationTestingRunner.php | 15 +-- .../e2e/Config_Bootstrap/expected-output.txt | 1 + tests/e2e/Custom_tmp_dir/expected-output.txt | 1 + tests/e2e/Empty_Path/expected-output.txt | 1 + tests/e2e/Example_Test/expected-output.txt | 1 + .../expected-output.txt | 1 + .../Exclude_by_file_name/expected-output.txt | 1 + tests/e2e/Exec_Path/expected-output.txt | 1 + .../Ignore_All_Mutations/expected-output.txt | 1 + .../expected-output.txt | 1 + tests/e2e/Memory_Limit/expected-output.txt | 1 + .../Multiline_Statement/expected-output.txt | 3 + tests/e2e/Output_Stream/expected-output.txt | 3 + tests/e2e/PCOV_Directory/expected-output.txt | 1 + tests/e2e/PCOV_PHPUnit8/expected-output.txt | 1 + tests/e2e/PHPUnit93/expected-output.txt | 1 + .../expected-output.txt | 1 + .../expected-output.txt | 1 + .../expected-output.txt | 1 + .../e2e/PSR_0_Autoloader/expected-output.txt | 1 + .../e2e/PestTestFramework/expected-output.txt | 1 + .../PhpUnit_Depends_Order/expected-output.txt | 1 + .../Phpunit_Bat_Wrapper/expected-output.txt | 1 + .../expected-output.txt | 1 + .../expected-output_phpunit.txt | 3 + .../expected-output.txt | 1 + .../expected-output_phpunit.txt | 3 + .../expected-output.txt | 1 + tests/e2e/SymfonyBridge/expected-output.txt | 1 + tests/e2e/SymfonyFlex/expected-output.txt | 1 + .../Syntax_Error_PHPUnit/expected-output.txt | 1 + .../e2e/Syntax_Error_Pest/expected-output.txt | 1 + .../expected-output.txt | 1 + .../expected-output.txt | 1 + tests/e2e/TimeoutSkipped/expected-output.txt | 1 + .../Variables_Order_EGPCS/expected-output.txt | 1 + tests/e2e/YieldValue/expected-output.txt | 8 +- .../OutputFormatter/DotFormatterTest.php | 27 ++++- .../OutputFormatterStyleConfiguratorTest.php | 2 +- .../Logger/CreateMetricsCalculator.php | 12 ++ tests/phpunit/Logger/DebugFileLoggerTest.php | 27 ++++- tests/phpunit/Logger/JsonLoggerTest.php | 104 +++++++++++++++++- tests/phpunit/Logger/PerMutatorLoggerTest.php | 12 +- .../phpunit/Logger/SummaryFileLoggerTest.php | 4 +- .../Runner/MutationTestingRunnerTest.php | 26 +++-- 58 files changed, 288 insertions(+), 59 deletions(-) diff --git a/infection.json b/infection.json index b10e0e7b4..d7f57129e 100644 --- a/infection.json +++ b/infection.json @@ -12,11 +12,6 @@ } }, "mutators": { - "@default": true, - "MethodCallRemoval": { - "ignore": [ - "Infection\\Finder\\SourceFilesFinder::__construct::63" - ] - } + "@default": true } } diff --git a/src/Console/OutputFormatter/DotFormatter.php b/src/Console/OutputFormatter/DotFormatter.php index 204964c35..b26dc0017 100644 --- a/src/Console/OutputFormatter/DotFormatter.php +++ b/src/Console/OutputFormatter/DotFormatter.php @@ -68,7 +68,8 @@ public function start(int $mutationCount): void . 'E: fatal error, ' . 'X: syntax error, ' . 'T: timed out, ' - . 'S: skipped', + . 'S: skipped, ' + . 'I: ignored', '', ]); } @@ -105,6 +106,10 @@ public function advance(MutantExecutionResult $executionResult, int $mutationCou case DetectionStatus::SYNTAX_ERROR: $this->output->write('X'); + break; + case DetectionStatus::IGNORED: + $this->output->write('I'); + break; } diff --git a/src/Console/OutputFormatterStyleConfigurator.php b/src/Console/OutputFormatterStyleConfigurator.php index 66e3bccbc..cdb7f3a4b 100644 --- a/src/Console/OutputFormatterStyleConfigurator.php +++ b/src/Console/OutputFormatterStyleConfigurator.php @@ -60,17 +60,12 @@ private static function configureMutantStyle(OutputFormatterInterface $formatter { $formatter->setStyle('with-error', new OutputFormatterStyle('green')); $formatter->setStyle('with-syntax-error', new OutputFormatterStyle('red', null, ['bold'])); - $formatter->setStyle( - 'uncovered', - new OutputFormatterStyle('blue', null, ['bold']) - ); + $formatter->setStyle('uncovered', new OutputFormatterStyle('blue', null, ['bold'])); $formatter->setStyle('timeout', new OutputFormatterStyle('yellow')); - $formatter->setStyle( - 'escaped', - new OutputFormatterStyle('red', null, ['bold']) - ); + $formatter->setStyle('escaped', new OutputFormatterStyle('red', null, ['bold'])); $formatter->setStyle('killed', new OutputFormatterStyle('green')); $formatter->setStyle('skipped', new OutputFormatterStyle('magenta')); + $formatter->setStyle('ignored', new OutputFormatterStyle('white')); $formatter->setStyle('code', new OutputFormatterStyle('white')); } diff --git a/src/Event/Subscriber/MutationTestingConsoleLoggerSubscriber.php b/src/Event/Subscriber/MutationTestingConsoleLoggerSubscriber.php index f18146864..2ef8b7c57 100644 --- a/src/Event/Subscriber/MutationTestingConsoleLoggerSubscriber.php +++ b/src/Event/Subscriber/MutationTestingConsoleLoggerSubscriber.php @@ -147,6 +147,7 @@ private function showMetrics(): void $this->output->writeln(['', '']); $this->output->writeln('' . $this->metricsCalculator->getTotalMutantsCount() . ' mutations were generated:'); $this->output->writeln('' . $this->getPadded($this->metricsCalculator->getKilledCount()) . ' mutants were killed'); + $this->output->writeln('' . $this->getPadded($this->metricsCalculator->getIgnoredCount()) . ' mutants were configured to be ignored'); $this->output->writeln('' . $this->getPadded($this->metricsCalculator->getNotTestedCount()) . ' mutants were not covered by tests'); $this->output->writeln('' . $this->getPadded($this->metricsCalculator->getEscapedCount()) . ' covered mutants were not detected'); $this->output->writeln('' . $this->getPadded($this->metricsCalculator->getErrorCount()) . ' errors were encountered'); diff --git a/src/Logger/DebugFileLogger.php b/src/Logger/DebugFileLogger.php index 9e6bbc3b0..7a64058e8 100644 --- a/src/Logger/DebugFileLogger.php +++ b/src/Logger/DebugFileLogger.php @@ -104,6 +104,11 @@ public function getLogLines(): array 'Skipped', $separateSections ); + $logs[] = $this->getResultsLine( + $this->resultsCollector->getIgnoredExecutionResults(), + 'Ignored', + $separateSections + ); if (!$this->onlyCoveredMode) { $logs[] = $this->getResultsLine( diff --git a/src/Logger/JsonLogger.php b/src/Logger/JsonLogger.php index daec409bd..ffa4d3432 100644 --- a/src/Logger/JsonLogger.php +++ b/src/Logger/JsonLogger.php @@ -76,6 +76,7 @@ public function getLogLines(): array 'errorCount' => $this->metricsCalculator->getErrorCount(), 'syntaxErrorCount' => $this->metricsCalculator->getSyntaxErrorCount(), 'skippedCount' => $this->metricsCalculator->getSkippedCount(), + 'ignoredCount' => $this->metricsCalculator->getIgnoredCount(), 'timeOutCount' => $this->metricsCalculator->getTimedOutCount(), 'msi' => $this->metricsCalculator->getMutationScoreIndicator(), 'mutationCodeCoverage' => $this->metricsCalculator->getCoverageRate(), @@ -87,6 +88,7 @@ public function getLogLines(): array 'errored' => $this->getResultsLine($this->resultsCollector->getErrorExecutionResults()), 'syntaxErrors' => $this->getResultsLine($this->resultsCollector->getSyntaxErrorExecutionResults()), 'uncovered' => $this->onlyCoveredMode ? [] : $this->getResultsLine($this->resultsCollector->getNotCoveredExecutionResults()), + 'ignored' => $this->getResultsLine($this->resultsCollector->getIgnoredExecutionResults()), ]; return [json_encode($data, JSON_THROW_ON_ERROR)]; @@ -101,7 +103,7 @@ private function getResultsLine(array $executionResults): array { $mutatorRows = []; - foreach ($executionResults as $index => $mutantProcess) { + foreach ($executionResults as $mutantProcess) { $mutatorRows[] = [ 'mutator' => [ 'mutatorName' => $mutantProcess->getMutatorName(), diff --git a/src/Logger/PerMutatorLogger.php b/src/Logger/PerMutatorLogger.php index 4dc8cece5..38ca1293d 100644 --- a/src/Logger/PerMutatorLogger.php +++ b/src/Logger/PerMutatorLogger.php @@ -73,7 +73,7 @@ public function getLogLines(): array $calculatorPerMutator = $this->createMetricsPerMutators(); $table = [ - ['Mutator', 'Mutations', 'Killed', 'Escaped', 'Errors', 'Syntax Errors', 'Timed Out', 'Skipped', 'MSI (%s)', 'Covered MSI (%s)'], + ['Mutator', 'Mutations', 'Killed', 'Escaped', 'Errors', 'Syntax Errors', 'Timed Out', 'Skipped', 'Ignored', 'MSI (%s)', 'Covered MSI (%s)'], ]; foreach ($calculatorPerMutator as $mutatorName => $calculator) { @@ -88,6 +88,7 @@ public function getLogLines(): array (string) $calculator->getSyntaxErrorCount(), (string) $calculator->getTimedOutCount(), (string) $calculator->getSkippedCount(), + (string) $calculator->getIgnoredCount(), self::formatScore($calculator->getMutationScoreIndicator()), self::formatScore($calculator->getCoveredCodeMutationScoreIndicator()), ]; diff --git a/src/Logger/SummaryFileLogger.php b/src/Logger/SummaryFileLogger.php index e9044b756..e32d86528 100644 --- a/src/Logger/SummaryFileLogger.php +++ b/src/Logger/SummaryFileLogger.php @@ -63,6 +63,7 @@ public function getLogLines(): array 'Escaped: ' . $this->metricsCalculator->getEscapedCount(), 'Timed Out: ' . $this->metricsCalculator->getTimedOutCount(), 'Skipped: ' . $this->metricsCalculator->getSkippedCount(), + 'Ignored: ' . $this->metricsCalculator->getIgnoredCount(), 'Not Covered: ' . $this->metricsCalculator->getNotTestedCount(), '', ]; diff --git a/src/Metrics/MetricsCalculator.php b/src/Metrics/MetricsCalculator.php index 527c99092..5e1a33e10 100644 --- a/src/Metrics/MetricsCalculator.php +++ b/src/Metrics/MetricsCalculator.php @@ -113,6 +113,11 @@ public function getSkippedCount(): int return $this->countByStatus[DetectionStatus::SKIPPED]; } + public function getIgnoredCount(): int + { + return $this->countByStatus[DetectionStatus::IGNORED]; + } + public function getEscapedCount(): int { return $this->countByStatus[DetectionStatus::ESCAPED]; @@ -135,7 +140,7 @@ public function getTotalMutantsCount(): int public function getTestedMutantsCount(): int { - return $this->getTotalMutantsCount() - $this->getSkippedCount(); + return $this->getTotalMutantsCount() - $this->getSkippedCount() - $this->getIgnoredCount(); } /** diff --git a/src/Metrics/ResultsCollector.php b/src/Metrics/ResultsCollector.php index 7078c560c..b46bd3f1b 100644 --- a/src/Metrics/ResultsCollector.php +++ b/src/Metrics/ResultsCollector.php @@ -73,7 +73,7 @@ public function collect(MutantExecutionResult ...$executionResults): void if (!array_key_exists($detectionStatus, $this->resultsByStatus)) { throw new InvalidArgumentException(sprintf( 'Unknown execution result process result code "%s"', - $executionResult->getDetectionStatus() + $detectionStatus )); } @@ -145,6 +145,14 @@ public function getNotCoveredExecutionResults(): array return $this->getResultListForStatus(DetectionStatus::NOT_COVERED)->getSortedExecutionResults(); } + /** + * @return MutantExecutionResult[] + */ + public function getIgnoredExecutionResults(): array + { + return $this->getResultListForStatus(DetectionStatus::IGNORED)->getSortedExecutionResults(); + } + private function getResultListForStatus(string $detectionStatus): SortableMutantExecutionResults { return $this->resultsByStatus[$detectionStatus]; diff --git a/src/Metrics/TargetDetectionStatusesProvider.php b/src/Metrics/TargetDetectionStatusesProvider.php index 6915bc2b9..d8eb068af 100644 --- a/src/Metrics/TargetDetectionStatusesProvider.php +++ b/src/Metrics/TargetDetectionStatusesProvider.php @@ -130,6 +130,8 @@ private function findRequired(): Generator if (!$this->onlyCoveredMode) { yield DetectionStatus::NOT_COVERED; } + + yield DetectionStatus::IGNORED; } // Follows the logic in TextFileLogger @@ -151,6 +153,8 @@ private function findRequired(): Generator if (!$this->onlyCoveredMode) { yield DetectionStatus::NOT_COVERED; } + + yield DetectionStatus::IGNORED; } } } diff --git a/src/Mutant/DetectionStatus.php b/src/Mutant/DetectionStatus.php index b3fcc4879..6d7de0896 100644 --- a/src/Mutant/DetectionStatus.php +++ b/src/Mutant/DetectionStatus.php @@ -51,6 +51,7 @@ final class DetectionStatus public const SKIPPED = 'skipped'; public const SYNTAX_ERROR = 'syntax error'; public const NOT_COVERED = 'not covered'; + public const IGNORED = 'ignored'; public const ALL = [ self::KILLED, @@ -60,5 +61,6 @@ final class DetectionStatus self::SKIPPED, self::SYNTAX_ERROR, self::NOT_COVERED, + self::IGNORED, ]; } diff --git a/src/Mutant/MutantExecutionResult.php b/src/Mutant/MutantExecutionResult.php index 5ffa86799..ba9b396d9 100644 --- a/src/Mutant/MutantExecutionResult.php +++ b/src/Mutant/MutantExecutionResult.php @@ -108,6 +108,11 @@ public static function createFromTimeSkippedMutant(Mutant $mutant): self return self::createFromMutant($mutant, DetectionStatus::SKIPPED); } + public static function createFromIgnoredMutant(Mutant $mutant): self + { + return self::createFromMutant($mutant, DetectionStatus::IGNORED); + } + public function getProcessCommandLine(): string { return $this->processCommandLine; diff --git a/src/Process/Runner/MutationTestingRunner.php b/src/Process/Runner/MutationTestingRunner.php index eca69a3ca..2874e11f6 100644 --- a/src/Process/Runner/MutationTestingRunner.php +++ b/src/Process/Runner/MutationTestingRunner.php @@ -35,7 +35,6 @@ namespace Infection\Process\Runner; -use function array_key_exists; use Infection\Differ\DiffSourceCodeMatcher; use Infection\Event\EventDispatcher\EventDispatcher; use Infection\Event\MutantProcessWasFinished; @@ -107,12 +106,12 @@ public function run(iterable $mutations, string $testFrameworkExtraOptions): voi ->filter(function (Mutant $mutant): bool { $mutatorName = $mutant->getMutation()->getMutatorName(); - if (!array_key_exists($mutatorName, $this->ignoreSourceCodeMutatorsMap)) { - return true; - } - - foreach ($this->ignoreSourceCodeMutatorsMap[$mutatorName] as $sourceCodeRegex) { + foreach ($this->ignoreSourceCodeMutatorsMap[$mutatorName] ?? [] as $sourceCodeRegex) { if ($this->diffSourceCodeMatcher->matches($mutant->getDiff()->get(), $sourceCodeRegex)) { + $this->eventDispatcher->dispatch(new MutantProcessWasFinished( + MutantExecutionResult::createFromIgnoredMutant($mutant) + )); + return false; } } @@ -146,9 +145,7 @@ public function run(iterable $mutations, string $testFrameworkExtraOptions): voi ->cast(function (Mutant $mutant) use ($testFrameworkExtraOptions): ProcessBearer { $this->fileSystem->dumpFile($mutant->getFilePath(), $mutant->getMutatedCode()->get()); - $process = $this->processFactory->createProcessForMutant($mutant, $testFrameworkExtraOptions); - - return $process; + return $this->processFactory->createProcessForMutant($mutant, $testFrameworkExtraOptions); }) ; diff --git a/tests/e2e/Config_Bootstrap/expected-output.txt b/tests/e2e/Config_Bootstrap/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Config_Bootstrap/expected-output.txt +++ b/tests/e2e/Config_Bootstrap/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Custom_tmp_dir/expected-output.txt b/tests/e2e/Custom_tmp_dir/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Custom_tmp_dir/expected-output.txt +++ b/tests/e2e/Custom_tmp_dir/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Empty_Path/expected-output.txt b/tests/e2e/Empty_Path/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Empty_Path/expected-output.txt +++ b/tests/e2e/Empty_Path/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Example_Test/expected-output.txt b/tests/e2e/Example_Test/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Example_Test/expected-output.txt +++ b/tests/e2e/Example_Test/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt b/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt index 95e73f9ca..48cec0aa0 100644 --- a/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt +++ b/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Exclude_by_file_name/expected-output.txt b/tests/e2e/Exclude_by_file_name/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Exclude_by_file_name/expected-output.txt +++ b/tests/e2e/Exclude_by_file_name/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Exec_Path/expected-output.txt b/tests/e2e/Exec_Path/expected-output.txt index c654acc50..bbe45bd41 100644 --- a/tests/e2e/Exec_Path/expected-output.txt +++ b/tests/e2e/Exec_Path/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 1 diff --git a/tests/e2e/Ignore_All_Mutations/expected-output.txt b/tests/e2e/Ignore_All_Mutations/expected-output.txt index b53522bf8..47f904f38 100644 --- a/tests/e2e/Ignore_All_Mutations/expected-output.txt +++ b/tests/e2e/Ignore_All_Mutations/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Ignore_MSI_Zero_Mutations/expected-output.txt b/tests/e2e/Ignore_MSI_Zero_Mutations/expected-output.txt index 95e73f9ca..48cec0aa0 100644 --- a/tests/e2e/Ignore_MSI_Zero_Mutations/expected-output.txt +++ b/tests/e2e/Ignore_MSI_Zero_Mutations/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Memory_Limit/expected-output.txt b/tests/e2e/Memory_Limit/expected-output.txt index 003c4078e..52f6f4adb 100644 --- a/tests/e2e/Memory_Limit/expected-output.txt +++ b/tests/e2e/Memory_Limit/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Multiline_Statement/expected-output.txt b/tests/e2e/Multiline_Statement/expected-output.txt index b975cd448..334fe11ef 100644 --- a/tests/e2e/Multiline_Statement/expected-output.txt +++ b/tests/e2e/Multiline_Statement/expected-output.txt @@ -61,5 +61,8 @@ Timed Out mutants: Skipped mutants: ================ +Ignored mutants: +================ + Not Covered mutants: ==================== diff --git a/tests/e2e/Output_Stream/expected-output.txt b/tests/e2e/Output_Stream/expected-output.txt index e887c84cd..934db7ecf 100644 --- a/tests/e2e/Output_Stream/expected-output.txt +++ b/tests/e2e/Output_Stream/expected-output.txt @@ -25,5 +25,8 @@ Timed Out mutants: Skipped mutants: ================ +Ignored mutants: +================ + Not Covered mutants: ==================== diff --git a/tests/e2e/PCOV_Directory/expected-output.txt b/tests/e2e/PCOV_Directory/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PCOV_Directory/expected-output.txt +++ b/tests/e2e/PCOV_Directory/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PCOV_PHPUnit8/expected-output.txt b/tests/e2e/PCOV_PHPUnit8/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PCOV_PHPUnit8/expected-output.txt +++ b/tests/e2e/PCOV_PHPUnit8/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PHPUnit93/expected-output.txt b/tests/e2e/PHPUnit93/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PHPUnit93/expected-output.txt +++ b/tests/e2e/PHPUnit93/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PHPUnit_Custom_Config_Dir/expected-output.txt b/tests/e2e/PHPUnit_Custom_Config_Dir/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PHPUnit_Custom_Config_Dir/expected-output.txt +++ b/tests/e2e/PHPUnit_Custom_Config_Dir/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PHPUnit_Hidden_Dependency/expected-output.txt b/tests/e2e/PHPUnit_Hidden_Dependency/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PHPUnit_Hidden_Dependency/expected-output.txt +++ b/tests/e2e/PHPUnit_Hidden_Dependency/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PHPUnit_XSD_Validation/expected-output.txt b/tests/e2e/PHPUnit_XSD_Validation/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PHPUnit_XSD_Validation/expected-output.txt +++ b/tests/e2e/PHPUnit_XSD_Validation/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PSR_0_Autoloader/expected-output.txt b/tests/e2e/PSR_0_Autoloader/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/PSR_0_Autoloader/expected-output.txt +++ b/tests/e2e/PSR_0_Autoloader/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PestTestFramework/expected-output.txt b/tests/e2e/PestTestFramework/expected-output.txt index 00e5e6f54..9dc0dfe33 100644 --- a/tests/e2e/PestTestFramework/expected-output.txt +++ b/tests/e2e/PestTestFramework/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 2 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/PhpUnit_Depends_Order/expected-output.txt b/tests/e2e/PhpUnit_Depends_Order/expected-output.txt index 95e73f9ca..48cec0aa0 100644 --- a/tests/e2e/PhpUnit_Depends_Order/expected-output.txt +++ b/tests/e2e/PhpUnit_Depends_Order/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Phpunit_Bat_Wrapper/expected-output.txt b/tests/e2e/Phpunit_Bat_Wrapper/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Phpunit_Bat_Wrapper/expected-output.txt +++ b/tests/e2e/Phpunit_Bat_Wrapper/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Profiles_Ignore_Combination/expected-output.txt b/tests/e2e/Profiles_Ignore_Combination/expected-output.txt index c0e51b061..6bab5b647 100644 --- a/tests/e2e/Profiles_Ignore_Combination/expected-output.txt +++ b/tests/e2e/Profiles_Ignore_Combination/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 4 diff --git a/tests/e2e/Provide_Existing_Coverage/expected-output_phpunit.txt b/tests/e2e/Provide_Existing_Coverage/expected-output_phpunit.txt index e2f0f5d54..a2efe12bb 100644 --- a/tests/e2e/Provide_Existing_Coverage/expected-output_phpunit.txt +++ b/tests/e2e/Provide_Existing_Coverage/expected-output_phpunit.txt @@ -40,6 +40,9 @@ Timed Out mutants: Skipped mutants: ================ +Ignored mutants: +================ + Not Covered mutants: ==================== diff --git a/tests/e2e/Save_PHPUnit_Bootstrap_File/expected-output.txt b/tests/e2e/Save_PHPUnit_Bootstrap_File/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Save_PHPUnit_Bootstrap_File/expected-output.txt +++ b/tests/e2e/Save_PHPUnit_Bootstrap_File/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Skip_Initial_Tests/expected-output_phpunit.txt b/tests/e2e/Skip_Initial_Tests/expected-output_phpunit.txt index 9323b3835..b6bc4edc6 100644 --- a/tests/e2e/Skip_Initial_Tests/expected-output_phpunit.txt +++ b/tests/e2e/Skip_Initial_Tests/expected-output_phpunit.txt @@ -40,6 +40,9 @@ Timed Out mutants: Skipped mutants: ================ +Ignored mutants: +================ + Not Covered mutants: ==================== diff --git a/tests/e2e/Source_Directories_Config/expected-output.txt b/tests/e2e/Source_Directories_Config/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Source_Directories_Config/expected-output.txt +++ b/tests/e2e/Source_Directories_Config/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/SymfonyBridge/expected-output.txt b/tests/e2e/SymfonyBridge/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/SymfonyBridge/expected-output.txt +++ b/tests/e2e/SymfonyBridge/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/SymfonyFlex/expected-output.txt b/tests/e2e/SymfonyFlex/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/SymfonyFlex/expected-output.txt +++ b/tests/e2e/SymfonyFlex/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Syntax_Error_PHPUnit/expected-output.txt b/tests/e2e/Syntax_Error_PHPUnit/expected-output.txt index b3a0bb786..159e107a6 100644 --- a/tests/e2e/Syntax_Error_PHPUnit/expected-output.txt +++ b/tests/e2e/Syntax_Error_PHPUnit/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 1 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Syntax_Error_Pest/expected-output.txt b/tests/e2e/Syntax_Error_Pest/expected-output.txt index b3a0bb786..159e107a6 100644 --- a/tests/e2e/Syntax_Error_Pest/expected-output.txt +++ b/tests/e2e/Syntax_Error_Pest/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 1 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Test_Framework_Options_Config/expected-output.txt b/tests/e2e/Test_Framework_Options_Config/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Test_Framework_Options_Config/expected-output.txt +++ b/tests/e2e/Test_Framework_Options_Config/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Test_PHP_Options_Config/expected-output.txt b/tests/e2e/Test_PHP_Options_Config/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Test_PHP_Options_Config/expected-output.txt +++ b/tests/e2e/Test_PHP_Options_Config/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/TimeoutSkipped/expected-output.txt b/tests/e2e/TimeoutSkipped/expected-output.txt index 129bf771f..9a809ba89 100644 --- a/tests/e2e/TimeoutSkipped/expected-output.txt +++ b/tests/e2e/TimeoutSkipped/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 2 Timed Out: 1 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/Variables_Order_EGPCS/expected-output.txt b/tests/e2e/Variables_Order_EGPCS/expected-output.txt index a31fc060f..e4dbc2085 100644 --- a/tests/e2e/Variables_Order_EGPCS/expected-output.txt +++ b/tests/e2e/Variables_Order_EGPCS/expected-output.txt @@ -6,4 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 diff --git a/tests/e2e/YieldValue/expected-output.txt b/tests/e2e/YieldValue/expected-output.txt index 1ce4f94ab..e4391b365 100644 --- a/tests/e2e/YieldValue/expected-output.txt +++ b/tests/e2e/YieldValue/expected-output.txt @@ -1,6 +1,6 @@ # Effects per Mutator -| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | MSI (%s) | Covered MSI (%s) | -| ---------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | -------- | ---------------- | -| YieldValue | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 | -| Yield_ | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 | +| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | Ignored | MSI (%s) | Covered MSI (%s) | +| ---------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | --------| -------- | ---------------- | +| YieldValue | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 | +| Yield_ | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 | diff --git a/tests/phpunit/Console/OutputFormatter/DotFormatterTest.php b/tests/phpunit/Console/OutputFormatter/DotFormatterTest.php index fd6768c6f..b3151a46e 100644 --- a/tests/phpunit/Console/OutputFormatter/DotFormatterTest.php +++ b/tests/phpunit/Console/OutputFormatter/DotFormatterTest.php @@ -60,7 +60,8 @@ public function test_start_logs_initial_starting_text(): void . 'E: fatal error, ' . 'X: syntax error, ' . 'T: timed out, ' - . 'S: skipped', + . 'S: skipped, ' + . 'I: ignored', '', ]); @@ -170,6 +171,23 @@ public function test_skipped_logs_correctly_in_console(): void ); } + public function test_ignored_logs_correctly_in_console(): void + { + $outputIgnored = $this->getStartOutputFormatter(); + $outputIgnored + ->expects($this->once()) + ->method('write') + ->with('I') + ; + + $dot = new DotFormatter($outputIgnored); + $dot->start(10); + $dot->advance( + $this->createMutantExecutionResultsOfType(DetectionStatus::IGNORED)[0], + 10 + ); + } + public function test_it_prints_total_number_of_mutations(): void { $totalMutations = self::ANY_PRIME_NUMBER; @@ -185,7 +203,7 @@ public function test_it_prints_total_number_of_mutations(): void $this->assertSame(str_replace("\n", PHP_EOL, <<<'TXT' -.: killed, M: escaped, U: uncovered, E: fatal error, X: syntax error, T: timed out, S: skipped +.: killed, M: escaped, U: uncovered, E: fatal error, X: syntax error, T: timed out, S: skipped, I: ignored .................................................. ( 50 / 127) .................................................. (100 / 127) @@ -214,7 +232,7 @@ public function test_it_prints_current_number_of_pending_mutations(): void $this->assertSame(str_replace("\n", PHP_EOL, <<<'TXT' -.: killed, M: escaped, U: uncovered, E: fatal error, X: syntax error, T: timed out, S: skipped +.: killed, M: escaped, U: uncovered, E: fatal error, X: syntax error, T: timed out, S: skipped, I: ignored .................................................. ( 50) .................................................. ( 100) @@ -255,7 +273,8 @@ private function getStartOutputFormatter() . 'E: fatal error, ' . 'X: syntax error, ' . 'T: timed out, ' - . 'S: skipped', + . 'S: skipped, ' + . 'I: ignored', '', ]); diff --git a/tests/phpunit/Console/OutputFormatterStyleConfiguratorTest.php b/tests/phpunit/Console/OutputFormatterStyleConfiguratorTest.php index 6c1214269..97e84749f 100644 --- a/tests/phpunit/Console/OutputFormatterStyleConfiguratorTest.php +++ b/tests/phpunit/Console/OutputFormatterStyleConfiguratorTest.php @@ -46,7 +46,7 @@ public function test_it_adds_styles(): void { $formatter = $this->createMock(OutputFormatterInterface::class); $formatter - ->expects($this->exactly(13)) + ->expects($this->exactly(14)) ->method('setStyle') ; diff --git a/tests/phpunit/Logger/CreateMetricsCalculator.php b/tests/phpunit/Logger/CreateMetricsCalculator.php index 70eabdda4..2e8380ea6 100644 --- a/tests/phpunit/Logger/CreateMetricsCalculator.php +++ b/tests/phpunit/Logger/CreateMetricsCalculator.php @@ -152,6 +152,18 @@ private function feedCollector(Collector $collector): void PregQuote::class, DetectionStatus::NOT_COVERED, 'notCovered#1' + ), + $this->createMutantExecutionResult( + 0, + For_::class, + DetectionStatus::IGNORED, + 'ignored#0' + ), + $this->createMutantExecutionResult( + 1, + PregQuote::class, + DetectionStatus::IGNORED, + 'ignored#1' ) ); } diff --git a/tests/phpunit/Logger/DebugFileLoggerTest.php b/tests/phpunit/Logger/DebugFileLoggerTest.php index bbe286361..172ca9900 100644 --- a/tests/phpunit/Logger/DebugFileLoggerTest.php +++ b/tests/phpunit/Logger/DebugFileLoggerTest.php @@ -86,6 +86,9 @@ public function metricsProvider(): iterable Skipped mutants: ================ +Ignored mutants: +================ + Not Covered mutants: ==================== @@ -97,7 +100,7 @@ public function metricsProvider(): iterable $this->createCompleteResultsCollector(), false, <<<'TXT' -Total: 14 +Total: 16 Killed mutants: =============== @@ -159,6 +162,16 @@ public function metricsProvider(): iterable Line 10 +Ignored mutants: +================ + +Mutator: PregQuote +Line 9 + +Mutator: For_ +Line 10 + + Not Covered mutants: ==================== @@ -176,7 +189,7 @@ public function metricsProvider(): iterable $this->createCompleteResultsCollector(), true, <<<'TXT' -Total: 14 +Total: 16 Killed mutants: =============== @@ -237,6 +250,16 @@ public function metricsProvider(): iterable Mutator: PregQuote Line 10 + +Ignored mutants: +================ + +Mutator: PregQuote +Line 9 + +Mutator: For_ +Line 10 + TXT ]; } diff --git a/tests/phpunit/Logger/JsonLoggerTest.php b/tests/phpunit/Logger/JsonLoggerTest.php index e5a05bab8..03d8b5ca2 100644 --- a/tests/phpunit/Logger/JsonLoggerTest.php +++ b/tests/phpunit/Logger/JsonLoggerTest.php @@ -84,6 +84,7 @@ public function metricsProvider(): iterable 'errorCount' => 0, 'syntaxErrorCount' => 0, 'skippedCount' => 0, + 'ignoredCount' => 0, 'timeOutCount' => 0, 'msi' => 0, 'mutationCodeCoverage' => 0, @@ -95,6 +96,7 @@ public function metricsProvider(): iterable 'errored' => [], 'syntaxErrors' => [], 'uncovered' => [], + 'ignored' => [], ], ]; @@ -104,13 +106,14 @@ public function metricsProvider(): iterable $this->createCompleteResultsCollector(), [ 'stats' => [ - 'totalMutantsCount' => 14, + 'totalMutantsCount' => 16, 'killedCount' => 2, 'notCoveredCount' => 2, 'escapedCount' => 2, 'errorCount' => 2, 'syntaxErrorCount' => 2, 'skippedCount' => 2, + 'ignoredCount' => 2, 'timeOutCount' => 2, 'msi' => 66.67, 'mutationCodeCoverage' => 83.33, @@ -237,6 +240,30 @@ public function metricsProvider(): iterable ], ], 'uncovered' => [], + 'ignored' => [ + [ + 'mutator' => [ + 'mutatorName' => 'PregQuote', + 'originalSourceCode' => ' ' 'foo/bar', + 'originalStartLine' => 9, + ], + 'diff' => str_replace("\n", PHP_EOL, "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'ignored#1';"), + 'processOutput' => 'process output', + ], + [ + 'mutator' => [ + 'mutatorName' => 'For_', + 'originalSourceCode' => ' ' 'foo/bar', + 'originalStartLine' => 10, + ], + 'diff' => str_replace("\n", PHP_EOL, "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'ignored#0';"), + 'processOutput' => 'process output', + ], + ], ], ]; @@ -253,6 +280,7 @@ public function metricsProvider(): iterable 'errorCount' => 0, 'syntaxErrorCount' => 0, 'skippedCount' => 0, + 'ignoredCount' => 0, 'timeOutCount' => 0, 'msi' => 0, 'mutationCodeCoverage' => 0, @@ -276,6 +304,48 @@ public function metricsProvider(): iterable 'processOutput' => 'process output', ], ], + 'ignored' => [], + ], + ]; + + yield 'Ignored mutations' => [ + true, + $this->createIgnoredMetricsCalculator(), + $this->createIgnoredResultsCollector(), + [ + 'stats' => [ + 'totalMutantsCount' => 1, + 'killedCount' => 0, + 'notCoveredCount' => 0, + 'escapedCount' => 0, + 'errorCount' => 0, + 'syntaxErrorCount' => 0, + 'skippedCount' => 0, + 'ignoredCount' => 1, + 'timeOutCount' => 0, + 'msi' => 0, + 'mutationCodeCoverage' => 0, + 'coveredCodeMsi' => 0, + ], + 'escaped' => [], + 'timeouted' => [], + 'killed' => [], + 'errored' => [], + 'syntaxErrors' => [], + 'uncovered' => [], + 'ignored' => [ + [ + 'mutator' => [ + 'mutatorName' => 'For_', + 'originalSourceCode' => ' ' 'foo/bar', + 'originalStartLine' => 10, + ], + 'diff' => str_replace("\n", PHP_EOL, "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'ignored#0';"), + 'processOutput' => 'process output', + ], + ], ], ]; @@ -292,6 +362,7 @@ public function metricsProvider(): iterable 'errorCount' => 0, 'syntaxErrorCount' => 0, 'skippedCount' => 0, + 'ignoredCount' => 0, 'timeOutCount' => 0, 'msi' => 0, 'mutationCodeCoverage' => 0, @@ -315,6 +386,7 @@ public function metricsProvider(): iterable 'processOutput' => 'process output', ], ], + 'ignored' => [], ], ]; } @@ -354,6 +426,36 @@ private function initUncoveredCollector(Collector $collector): void ); } + private function createIgnoredMetricsCalculator(): MetricsCalculator + { + $collector = new MetricsCalculator(2); + + $this->initIgnoredCollector($collector); + + return $collector; + } + + private function createIgnoredResultsCollector(): ResultsCollector + { + $collector = new ResultsCollector(); + + $this->initIgnoredCollector($collector); + + return $collector; + } + + private function initIgnoredCollector(Collector $collector): void + { + $collector->collect( + $this->createMutantExecutionResult( + 0, + For_::class, + DetectionStatus::IGNORED, + 'ignored#0' + ), + ); + } + private function createNonUtf8CharactersCollector(): ResultsCollector { $collector = new ResultsCollector(); diff --git a/tests/phpunit/Logger/PerMutatorLoggerTest.php b/tests/phpunit/Logger/PerMutatorLoggerTest.php index 4c4455c15..0d4bba5e6 100644 --- a/tests/phpunit/Logger/PerMutatorLoggerTest.php +++ b/tests/phpunit/Logger/PerMutatorLoggerTest.php @@ -66,8 +66,8 @@ public function metricsProvider(): iterable <<<'TXT' # Effects per Mutator -| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | MSI (%s) | Covered MSI (%s) | -| ------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | -------- | ---------------- | +| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | Ignored | MSI (%s) | Covered MSI (%s) | +| ------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | ------- | -------- | ---------------- | TXT ]; @@ -78,10 +78,10 @@ public function metricsProvider(): iterable <<<'TXT' # Effects per Mutator -| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | MSI (%s) | Covered MSI (%s) | -| --------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | -------- | ---------------- | -| For_ | 7 | 1 | 1 | 1 | 1 | 1 | 1 | 66.67 | 80.00 | -| PregQuote | 7 | 1 | 1 | 1 | 1 | 1 | 1 | 66.67 | 80.00 | +| Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | Ignored | MSI (%s) | Covered MSI (%s) | +| --------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | ------- | -------- | ---------------- | +| For_ | 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 66.67 | 80.00 | +| PregQuote | 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 66.67 | 80.00 | TXT ]; diff --git a/tests/phpunit/Logger/SummaryFileLoggerTest.php b/tests/phpunit/Logger/SummaryFileLoggerTest.php index 3abb453e5..0fa824b01 100644 --- a/tests/phpunit/Logger/SummaryFileLoggerTest.php +++ b/tests/phpunit/Logger/SummaryFileLoggerTest.php @@ -69,6 +69,7 @@ public function metricsProvider(): iterable Escaped: 0 Timed Out: 0 Skipped: 0 +Ignored: 0 Not Covered: 0 TXT @@ -77,7 +78,7 @@ public function metricsProvider(): iterable yield 'all mutations' => [ $this->createCompleteMetricsCalculator(), <<<'TXT' -Total: 14 +Total: 16 Killed: 2 Errored: 2 @@ -85,6 +86,7 @@ public function metricsProvider(): iterable Escaped: 2 Timed Out: 2 Skipped: 2 +Ignored: 2 Not Covered: 2 TXT diff --git a/tests/phpunit/Process/Runner/MutationTestingRunnerTest.php b/tests/phpunit/Process/Runner/MutationTestingRunnerTest.php index e712d7dd6..811af297a 100644 --- a/tests/phpunit/Process/Runner/MutationTestingRunnerTest.php +++ b/tests/phpunit/Process/Runner/MutationTestingRunnerTest.php @@ -45,6 +45,7 @@ use Infection\Event\MutantProcessWasFinished; use Infection\Event\MutationTestingWasFinished; use Infection\Event\MutationTestingWasStarted; +use Infection\Mutant\MutantExecutionResult; use Infection\Mutant\MutantFactory; use Infection\Mutation\Mutation; use Infection\Mutator\Loop\For_; @@ -312,20 +313,20 @@ public function test_it_does_not_create_processes_when_code_is_ignored_by_regex( $testFrameworkExtraOptions = '--filter=acme/FooTest.php'; + $mutant = MutantBuilder::build( + '/path/to/mutant0', + $mutation0, + 'mutated code 0', + '- Assert::integer(1)', + 'mutantFactoryMock ->method('create') ->withConsecutive( [$mutation0], ) - ->willReturnOnConsecutiveCalls( - MutantBuilder::build( - '/path/to/mutant0', - $mutation0, - 'mutated code 0', - '- Assert::integer(1)', - 'willReturnOnConsecutiveCalls($mutant) ; $this->fileSystemMock @@ -363,6 +364,7 @@ public function test_it_does_not_create_processes_when_code_is_ignored_by_regex( $this->assertAreSameEvents( [ new MutationTestingWasStarted(0), + new MutantProcessWasFinished(MutantExecutionResult::createFromNonCoveredMutant($mutant)), new MutationTestingWasFinished(), ], $this->eventDispatcher->getEvents() @@ -458,18 +460,18 @@ private function assertAreSameEvents(array $expectedEvents, array $actualEvents) $this->assertIsInstanceOfAny($expectedClasses, $expectedEvent); $this->assertArrayHasKey($index, $actualEvents, $assertionErrorMessage); - $exepectedEventClass = get_class($expectedEvent); + $expectedEventClass = get_class($expectedEvent); // Handle mocks foreach ($expectedClasses as $expectedClassName) { if ($expectedEvent instanceof $expectedClassName) { - $exepectedEventClass = $expectedClassName; + $expectedEventClass = $expectedClassName; } } $event = $actualEvents[$index]; $this->assertInstanceOf( - $exepectedEventClass, + $expectedEventClass, $event, $assertionErrorMessage ); From b19c79177067f46c902e6775617d63d21195130f Mon Sep 17 00:00:00 2001 From: Oleg Zhulnev Date: Sun, 12 Dec 2021 22:25:17 +0300 Subject: [PATCH 2/3] Fix Exclude_Mutations_By_Regex e2e test --- tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt b/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt index 48cec0aa0..6af096d1b 100644 --- a/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt +++ b/tests/e2e/Exclude_Mutations_By_Regex/expected-output.txt @@ -1,4 +1,4 @@ -Total: 0 +Total: 4 Killed: 0 Errored: 0 @@ -6,5 +6,5 @@ Syntax Errors: 0 Escaped: 0 Timed Out: 0 Skipped: 0 -Ignored: 0 +Ignored: 4 Not Covered: 0 From 5e4b2a5731366ebc86dd8ccf0db5476efb5c6efc Mon Sep 17 00:00:00 2001 From: Oleg Zhulnev Date: Sun, 12 Dec 2021 22:37:51 +0300 Subject: [PATCH 3/3] Fix syntax error in YieldValue e2e test --- tests/e2e/YieldValue/expected-output.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/YieldValue/expected-output.txt b/tests/e2e/YieldValue/expected-output.txt index e4391b365..941267a6e 100644 --- a/tests/e2e/YieldValue/expected-output.txt +++ b/tests/e2e/YieldValue/expected-output.txt @@ -1,6 +1,6 @@ # Effects per Mutator | Mutator | Mutations | Killed | Escaped | Errors | Syntax Errors | Timed Out | Skipped | Ignored | MSI (%s) | Covered MSI (%s) | -| ---------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | --------| -------- | ---------------- | +| ---------- | --------- | ------ | ------- | ------ | ------------- | --------- | ------- | ------- | -------- | ---------------- | | YieldValue | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 | | Yield_ | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 50.00 | 100.00 |