Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging correction of lobster-cpptest tool #93

Merged
merged 5 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
14 changes: 7 additions & 7 deletions lobster/tools/cpptest/parser/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>\d+))"
.format(self.CODEBEAMER_LINK))
.format(self.codebeamer_link))
self.requirement_tag_http_named = (r"({}(?P<number>\d+))"
.format(self.codebeamer_link))

NON_EXISTING_INFO = "---"

Expand Down
4 changes: 2 additions & 2 deletions lobster/tools/cpptest/parser/requirements_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
20 changes: 11 additions & 9 deletions lobster/tools/cpptest/parser/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ 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.

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]:
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion packages/lobster-tool-cpptest/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
pycodestyle==2.12.0
pylint==3.2.4
coverage>=7.2
setuptools==75.1.0
Loading