From 664765c2026c2efc0daa57be355148c133d121a2 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Thu, 20 Mar 2025 10:44:15 +0100 Subject: [PATCH] if no 'jacoco.xml' file was found, throwing an error --- handlers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handlers.py b/handlers.py index 0de93c4..6dde2b4 100644 --- a/handlers.py +++ b/handlers.py @@ -205,10 +205,17 @@ class MavenHandler(BuildHandler): def get_jacoco_report_paths(self) -> Iterable[str]: # yield os.path.join(self.path, "target/site/jacoco-aggregate/jacoco.xml") - for root, _, files in os.walk(os.path.join(self.path, "target", "site")): + found_at_least_one = False + for root, _, files in os.walk(os.path.join(self.path)): + if "target/site" not in root: + continue # to avoid any misleading jacoco.xml randomly lying around for file in files: if file == "jacoco.xml": + found_at_least_one = True yield os.path.join(root, file) + if not found_at_least_one: + raise NoCoverageReportFound(f"Couldn't find any 'jacoco.xml' in {self.path}") + class GradleHandler(BuildHandler): def __init__(self, repo_path: str, build_file: str, updates: dict) -> None: super().__init__(repo_path, build_file, updates)