Skip to content

Commit

Permalink
fix crash when no test
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Dec 17, 2023
1 parent 143e6ac commit 68d1bc9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
suittest: ["normal", "with_plugin"]
suittest: ["normal", "with_plugin", "no_test"]
php: ["8.1", "8.2", "8.3"]

steps:
Expand Down
21 changes: 15 additions & 6 deletions src/PmmpUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ protected function onEnable() : void {
$this->test->run()
->then(function () {
$this->finish();
});
})
->catch(function (\Throwable $e) {
$this->getLogger()->logException($e);
$this->finish();
});
}), 0);
}

Expand Down Expand Up @@ -147,11 +151,16 @@ private function finish(bool $close = true) : void {
}
}

$this->getLogger()->notice("Total tests: " . count($results));
$this->getLogger()->info(" Total passed: " . count($passedTests) . " (" . round(count($passedTests) / count($results) * 100, 2) . "%)");
$this->getLogger()->info((count($failedTests) > 0 ? "§4" : "") . " Total failed: " . count($failedTests) . " (" . round(count($failedTests) / count($results) * 100, 2) . "%)");
$this->getLogger()->info((count($fatalErrors) > 0 ? "§c" : "") . " Total fatal: " . count($fatalErrors) . " (" . round(count($fatalErrors) / count($results) * 100, 2) . "%)");
$this->getLogger()->info($heatmap);
if(count($results) > 0) {
$this->getLogger()->notice("Total tests: " . count($results));
$this->getLogger()->info(" Total passed: " . count($passedTests) . " (" . round(count($passedTests) / count($results) * 100, 2) . "%)");
$this->getLogger()->info((count($failedTests) > 0 ? "§4" : "") . " Total failed: " . count($failedTests) . " (" . round(count($failedTests) / count($results) * 100, 2) . "%)");
$this->getLogger()->info((count($fatalErrors) > 0 ? "§c" : "") . " Total fatal: " . count($fatalErrors) . " (" . round(count($fatalErrors) / count($results) * 100, 2) . "%)");
$this->getLogger()->info($heatmap);
} else {
$this->getLogger()->notice("No tests were run.");
}


$this->getLogger()->notice("=== ============ ===");

Expand Down
Empty file.
Empty file.

0 comments on commit 68d1bc9

Please sign in to comment.