Coverage for lobster/tools/core/ci_report/ci_report.py: 0%

25 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-26 14:55 +0000

1#!/usr/bin/env python3 

2# 

3# lobster_ci_report - Visualise LOBSTER issues for CI 

4# Copyright (C) 2023-2024 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/>. 

19 

20import sys 

21import os.path 

22import argparse 

23 

24from lobster.report import Report 

25from lobster.items import Tracing_Status 

26from lobster.version import get_version 

27 

28 

29ap = argparse.ArgumentParser() 

30 

31 

32@get_version(ap) 

33def main(): 

34 # lobster-trace: core_ci_report_req.Dummy_Requirement 

35 ap.add_argument("lobster_report", 

36 nargs="?", 

37 default="report.lobster") 

38 options = ap.parse_args() 

39 

40 if not os.path.isfile(options.lobster_report): 

41 if options.lobster_report == "report.lobster": 

42 ap.error("specify report file") 

43 else: 

44 ap.error("%s is not a file" % options.lobster_report) 

45 

46 report = Report() 

47 report.load_report(options.lobster_report) 

48 

49 for uid in sorted(report.items): 

50 item = report.items[uid] 

51 if item.tracing_status not in (Tracing_Status.OK, 

52 Tracing_Status.JUSTIFIED): 

53 for message in item.messages: 

54 report.mh.error(item.location, 

55 message, 

56 fatal = False) 

57 

58 if report.mh.errors: 

59 return 1 

60 else: 

61 return 0 

62 

63 

64if __name__ == "__main__": 

65 sys.exit(main())