Coverage for lobster/tools/core/ci_report/ci_report.py: 0%
26 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-06 09:51 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-06 09:51 +0000
1#!/usr/bin/env python3
2#
3# lobster_ci_report - Visualise LOBSTER issues for CI
4# Copyright (C) 2023-2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public
17# License along with this program. If not, see
18# <https://www.gnu.org/licenses/>.
20from argparse import Namespace
21import os.path
23from lobster.report import Report
24from lobster.items import Tracing_Status
25from lobster.meta_data_tool_base import MetaDataToolBase
28class CiReportTool(MetaDataToolBase):
29 def __init__(self):
30 super().__init__(
31 name="lobster-ci-report",
32 description="Command line tool to check a LOBSTER report",
33 official=True,
34 )
36 self._argument_parser.add_argument(
37 "lobster_report",
38 nargs="?",
39 default="report.lobster",
40 )
42 def _run_impl(self, options: Namespace) -> int:
43 if not os.path.isfile(options.lobster_report):
44 if options.lobster_report == "report.lobster":
45 self._argument_parser.error("specify report file")
46 else:
47 self._argument_parser.error(f"{options.lobster_report} is not a file")
49 report = Report()
50 report.load_report(options.lobster_report)
52 for uid in sorted(report.items):
53 item = report.items[uid]
54 if item.tracing_status not in (Tracing_Status.OK,
55 Tracing_Status.JUSTIFIED):
56 for message in item.messages:
57 report.mh.error(item.location,
58 message,
59 fatal = False)
61 if report.mh.errors:
62 return 1
63 else:
64 return 0
67def main() -> int:
68 return CiReportTool().run()