From 6cabcba397182e4b8f372ea2007f16004961ec0c Mon Sep 17 00:00:00 2001 From: maks-rafalko Date: Sat, 7 Aug 2021 19:08:41 +0300 Subject: [PATCH] Do not mark Mutant ask Killed when no tests were executed Related to https://github.com/infection/infection/issues/1545 --- src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php | 5 ++++- .../TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php b/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php index 03326c597..5258633b1 100644 --- a/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php +++ b/src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php @@ -136,7 +136,10 @@ public function testsPass(string $output): bool // "Warnings!" - e.g. when deprecated functions are used, but tests pass $isWarning = preg_match('/warnings!/i', $output); - return $isOk || $isOkWithInfo || $isWarning; + // "No tests executed!" - e.g. when --filter option contains too large regular expression + $isNoTestsExecuted = preg_match('/No tests executed!/i', $output); + + return $isOk || $isOkWithInfo || $isWarning | $isNoTestsExecuted; } public function getMemoryUsed(string $output): float diff --git a/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php b/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php index 6410d8b5a..eb9d9b56e 100644 --- a/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php +++ b/tests/phpunit/TestFramework/PhpUnit/Adapter/PhpUnitAdapterTest.php @@ -275,6 +275,8 @@ public function outputProvider(): iterable yield ['FAILURES!', false]; yield ['ERRORS!', false]; + + yield ['No tests executed!', true]; } public function memoryReportProvider(): iterable