From 60c1e5abcbdbe30241d98e6464fd09d96f1510ca Mon Sep 17 00:00:00 2001 From: maks-rafalko Date: Sun, 29 Aug 2021 13:20:11 +0300 Subject: [PATCH] Display time and consumed memory even in case of insufficient MSI `Time: 3s. Memory: 15Mb` - this is printed on `ApplicationExecutionWasFinished` event, but if MSI check fails, exception is thrown and `ApplicationExecutionWasFinished` is not dispatched, so time and memory is not printed. This change fixes the issue. Now, `ApplicationExecutionWasFinished` event is dispatched regardless of thrown exception --- src/Engine.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Engine.php b/src/Engine.php index f72d43b80..50302ce44 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -110,14 +110,16 @@ public function execute(): void $this->runInitialTestSuite(); $this->runMutationAnalysis(); - $this->minMsiChecker->checkMetrics( - $this->metricsCalculator->getTestedMutantsCount(), - $this->metricsCalculator->getMutationScoreIndicator(), - $this->metricsCalculator->getCoveredCodeMutationScoreIndicator(), - $this->consoleOutput - ); - - $this->eventDispatcher->dispatch(new ApplicationExecutionWasFinished()); + try { + $this->minMsiChecker->checkMetrics( + $this->metricsCalculator->getTestedMutantsCount(), + $this->metricsCalculator->getMutationScoreIndicator(), + $this->metricsCalculator->getCoveredCodeMutationScoreIndicator(), + $this->consoleOutput + ); + } finally { + $this->eventDispatcher->dispatch(new ApplicationExecutionWasFinished()); + } } private function runInitialTestSuite(): void