diff --git a/Makefile b/Makefile index 08bf1534..79e7097a 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ packages: make -C packages/lobster-tool-trlc make -C packages/lobster-tool-codebeamer make -C packages/lobster-tool-cpp + make -C packages/lobster-tool-cpptest make -C packages/lobster-tool-gtest make -C packages/lobster-tool-json make -C packages/lobster-tool-python diff --git a/lobster/tools/cpptest/parser/__init__.py b/lobster/tools/cpptest/parser/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lobster/tools/cpptest/parser/constants.py b/lobster/tools/cpptest/parser/constants.py index dd81ba87..ee69cbcc 100644 --- a/lobster/tools/cpptest/parser/constants.py +++ b/lobster/tools/cpptest/parser/constants.py @@ -4,15 +4,15 @@ class Constants: def __init__(self, codebeamer_url = ''): - self.CODEBEAMER_LINK = codebeamer_url + "/issue/" - self.REQUIREMENT = re.compile(r".*[@\\]requirement\s+" + self.codebeamer_link = codebeamer_url + "/issue/" + self.requirement = re.compile(r".*[@\\]requirement\s+" r"([\s*/]*(((CB-#)|({}))\d+)\s*,?)+" - .format(self.CODEBEAMER_LINK)) - self.REQUIREMENT_TAG_HTTP = ((r"([@\\]requirement(\s+" + .format(self.codebeamer_link)) + self.requirement_tag_http = ((r"([@\\]requirement(\s+" r"(CB-#\d+\s+)*({}\d+\s*,?\s*/*\*?)+)+)") - .format(self.CODEBEAMER_LINK)) - self.REQUIREMENT_TAG_HTTP_NAMED = (r"({}(?P\d+))" - .format(self.CODEBEAMER_LINK)) + .format(self.codebeamer_link)) + self.requirement_tag_http_named = (r"({}(?P\d+))" + .format(self.codebeamer_link)) NON_EXISTING_INFO = "---" diff --git a/lobster/tools/cpptest/parser/requirements_parser.py b/lobster/tools/cpptest/parser/requirements_parser.py index b0d68e70..80a952f1 100644 --- a/lobster/tools/cpptest/parser/requirements_parser.py +++ b/lobster/tools/cpptest/parser/requirements_parser.py @@ -62,8 +62,8 @@ def collect_test_cases( with open(file, "r", encoding="UTF-8", errors="ignore") as f: lines = f.readlines() - except Exception as e: - logging.error(f"exception {e}") + except Exception as e: # pylint: disable=broad-exception-caught + logging.error("exception %s", e) return [] test_cases = [] diff --git a/lobster/tools/cpptest/parser/test_case.py b/lobster/tools/cpptest/parser/test_case.py index 3ca059a2..5f41c4fd 100644 --- a/lobster/tools/cpptest/parser/test_case.py +++ b/lobster/tools/cpptest/parser/test_case.py @@ -90,7 +90,7 @@ def _set_test_details(self, lines, start_idx) -> None: self.docu_lines = " ".join(self.docu_lines) self._set_base_attributes() - def _definition_end(self, lines, start_idx, char=["{", "}"]) -> int: + def _definition_end(self, lines, start_idx) -> int: """ Function to find the last line of test case definition, i.e. the closing brace. @@ -98,6 +98,7 @@ def _definition_end(self, lines, start_idx, char=["{", "}"]) -> int: lines -- lines to parse start_idx -- index into lines where to start parsing """ + char = ["{", "}"] nbraces = 0 while start_idx < len(lines): for character in lines[start_idx]: @@ -121,10 +122,10 @@ def _set_test_and_suite_name(self, src) -> None: def _set_base_attributes(self) -> None: self._get_requirements_from_docu_lines( - self.constants.REQUIREMENT, + self.constants.requirement, self.constants.REQUIREMENT_TAG, - self.constants.REQUIREMENT_TAG_HTTP, - self.constants.REQUIREMENT_TAG_HTTP_NAMED + self.constants.requirement_tag_http, + self.constants.requirement_tag_http_named ) self.required_by = self._get_require_tags( @@ -238,6 +239,7 @@ def is_line_commented(lines, start_idx) -> bool: return True return False + @staticmethod def has_no_macro_or_commented(lines, start_idx) -> bool: return TestCase.has_no_macro_or_commented_general( lines, @@ -274,8 +276,8 @@ def is_special_case(lines, test_case) -> bool: (test_case.docu_start_line - 1, test_case.docu_end_line) ): return True - elif (test_case.suite_name == Constants.NON_EXISTING_INFO or - test_case.test_name == Constants.NON_EXISTING_INFO): + elif Constants.NON_EXISTING_INFO in (test_case.suite_name, + test_case.test_name): return True return False @@ -342,7 +344,7 @@ def _get_uri_from_requirement_detection(requirement, tag_http_named): @staticmethod def _add_new_requirement_to_requirement_list( - self, + testcase, requirement_uri, tag_http_named ): @@ -366,8 +368,8 @@ def _add_new_requirement_to_requirement_list( requirement_number = ( requirement_number_dictionary.get("number")) requirement_cb = "CB-#" + requirement_number - if requirement_cb not in self.requirements: - self.requirements.append(requirement_cb) + if requirement_cb not in testcase.requirements: + testcase.requirements.append(requirement_cb) @staticmethod def _get_require_tags(match, filter_regex): diff --git a/packages/lobster-tool-cpptest/setup.py b/packages/lobster-tool-cpptest/setup.py index c011a14c..9c0423ca 100644 --- a/packages/lobster-tool-cpptest/setup.py +++ b/packages/lobster-tool-cpptest/setup.py @@ -55,7 +55,7 @@ url=project_urls["Source Code"], project_urls=project_urls, license="GNU Affero General Public License v3", - packages=["lobster.tools.cpptest"], + packages=["lobster.tools.cpptest","lobster.tools.cpptest.parser"], install_requires=package_requirements, python_requires=">=3.7, <4", classifiers=[ diff --git a/requirements_dev.txt b/requirements_dev.txt index 700430d4..c8e06321 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,3 +2,4 @@ pycodestyle==2.12.0 pylint==3.2.4 coverage>=7.2 +setuptools==75.1.0