From 896ca5ab105e4e3ffac1b05b85345c86038fc00f Mon Sep 17 00:00:00 2001 From: maks-rafalko Date: Tue, 20 Jul 2021 23:36:24 +0300 Subject: [PATCH] Add Mutator information to GitHub annotation logger * It will give more information about what Mutator is used and will be in line with other loggers * It will make it clear to understand why the diff can be empty, like in https://github.com/infection/infection/issues/1524 Fixes https://github.com/infection/infection/issues/1524 --- src/Logger/GitHubAnnotationsLogger.php | 2 +- tests/phpunit/Logger/GitHubAnnotationsLoggerTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Logger/GitHubAnnotationsLogger.php b/src/Logger/GitHubAnnotationsLogger.php index f9dd19e04..a12a2845f 100644 --- a/src/Logger/GitHubAnnotationsLogger.php +++ b/src/Logger/GitHubAnnotationsLogger.php @@ -63,7 +63,7 @@ public function getLogLines(): array $error = [ 'line' => $escapedExecutionResult->getOriginalStartingLine(), 'message' => <<<"TEXT" -Escaped Mutant: +Escaped Mutant for Mutator "{$escapedExecutionResult->getMutatorName()}": {$escapedExecutionResult->getMutantDiff()} TEXT diff --git a/tests/phpunit/Logger/GitHubAnnotationsLoggerTest.php b/tests/phpunit/Logger/GitHubAnnotationsLoggerTest.php index 49dde03c4..7ce80f468 100644 --- a/tests/phpunit/Logger/GitHubAnnotationsLoggerTest.php +++ b/tests/phpunit/Logger/GitHubAnnotationsLoggerTest.php @@ -68,8 +68,8 @@ public function metricsProvider(): iterable yield 'all mutations' => [ $this->createCompleteResultsCollector(), [ - "::warning file=foo/bar,line=9::Escaped Mutant:%0A%0A--- Original%0A+++ New%0A@@ @@%0A%0A- echo 'original';%0A+ echo 'escaped#1';%0A\n", - "::warning file=foo/bar,line=10::Escaped Mutant:%0A%0A--- Original%0A+++ New%0A@@ @@%0A%0A- echo 'original';%0A+ echo 'escaped#0';%0A\n", + "::warning file=foo/bar,line=9::Escaped Mutant for Mutator \"PregQuote\":%0A%0A--- Original%0A+++ New%0A@@ @@%0A%0A- echo 'original';%0A+ echo 'escaped#1';%0A\n", + "::warning file=foo/bar,line=10::Escaped Mutant for Mutator \"For_\":%0A%0A--- Original%0A+++ New%0A@@ @@%0A%0A- echo 'original';%0A+ echo 'escaped#0';%0A\n", ], ]; }