Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andmat900 committed Jun 7, 2024
1 parent bce67fd commit 3fc3b26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
17 changes: 12 additions & 5 deletions src/etos_test_runner/lib/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
from etos_test_runner.lib.log_area import LogArea
from etos_test_runner.lib.verdict import CustomVerdictMatcher


class TestRunner:
"""Test runner for ETOS."""

# pylint: disable=too-many-instance-attributes

logger = logging.getLogger("ETR")

def __init__(self, iut, etos):
Expand Down Expand Up @@ -58,8 +61,6 @@ def __init__(self, iut, etos):
rules = []

self.verdict_matcher = CustomVerdictMatcher(rules)
self.test_framework_exit_codes = []


def test_suite_started(self):
"""Publish a test suite started event.
Expand Down Expand Up @@ -131,7 +132,11 @@ def run_tests(self, workspace: Workspace) -> tuple[bool, list[Union[int, None]]]
return result, test_framework_exit_codes

def outcome(
self, result: bool, executed: bool, description: str, test_framework_exit_codes: list[Union[int, None]]
self,
result: bool,
executed: bool,
description: str,
test_framework_exit_codes: list[Union[int, None]],
) -> dict:
"""Get outcome from test execution.
Expand All @@ -154,8 +159,10 @@ def outcome(
verdict = custom_verdict["verdict"]
description = custom_verdict["description"]
except KeyError as err:
raise ValueError(f"Malformed entry in the verdict rule file: {custom_verdict}. "
"Expected attributes: description, condition, conclusion, verdict.") from err
raise ValueError(
f"Malformed entry in the verdict rule file: {custom_verdict}. "
"Expected attributes: description, condition, conclusion, verdict."
) from err
self.logger.info("Verdict matches testrunner verdict rule: %s", custom_verdict)
elif executed:
conclusion = "SUCCESSFUL"
Expand Down
10 changes: 5 additions & 5 deletions src/etos_test_runner/lib/verdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ def __init__(self, rules: list) -> None:
def _evaluate_rule(self, rule: dict, test_framework_output: dict) -> bool:
"""Evaluate conditions within the given rule."""
for kw, expected_value in rule["condition"].items():
# If the condition has multiple expressions, they are implicitly joined using logical AND:
# i. e. all shall evaluate to True in order for the condition to be True.
# If the condition has multiple expressions, they are implicitly
# joined using logical AND: i. e. all shall evaluate to True
# in order for the condition to be True.
# False is returned as soon as a false statement is encountered.
if kw == "test_framework_exit_code":
# If the exit code given by the condition is found in the list of produced exit codes,
# the rule will evaluate as True.
# If the exit code given by the condition is found in
# the list of produced exit codes, the rule will evaluate as True.
if expected_value not in test_framework_output.get("test_framework_exit_codes"):
return False
return True
Expand All @@ -73,4 +74,3 @@ def evaluate(self, test_framework_output: dict) -> Union[dict, None]:
if self._evaluate_rule(rule, test_framework_output):
return rule
return None

0 comments on commit 3fc3b26

Please sign in to comment.