Skip to content

Commit

Permalink
trunner: fix handling TEST_IGNORE_MESSAGE
Browse files Browse the repository at this point in the history
JIRA CI-244
  • Loading branch information
mateusz-bloch authored and jsarzy committed Apr 6, 2023
1 parent fe522b7 commit 549e819
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions trunner/harness/unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def _format_result_output(results: Sequence[Dict[str, Any]], ctx: TestContext) -
out += green("OK")
elif res["status"] == "IGNORE":
out += yellow("IGNORE")
if "msg" in res:
out += ": " + res["msg"]
elif res["status"] == "INFO":
out += blue("INFO")

Expand All @@ -31,13 +33,13 @@ def _format_result_output(results: Sequence[Dict[str, Any]], ctx: TestContext) -


def unity_harness(dut: Dut, ctx: TestContext) -> Optional[TestResult]:
assert_re = r"ASSERTION (?P<path>.*?):(?P<line>\d+):(?P<status>FAIL|INFO|IGNORE): (?P<msg>.*?)\r"
assert_re = r"ASSERTION (?P<path>[\S]+):(?P<line>\d+):(?P<status>FAIL|INFO|IGNORE): (?P<msg>.*?)\r"
result_re = r"TEST\((?P<group>\w+), (?P<name>\w+)\) (?P<status>PASS|IGNORE)"
# Fail need to have its own regex due to greedy matching
result_final_re = r"TEST\((?P<group>\w+), (?P<name>\w+)\) (?P<status>FAIL) at (?P<path>.*?):(?P<line>\d+)\r"
final_re = r"(?P<total>\d+) Tests (?P<fail>\d+) Failures (?P<ignore>\d+) Ignored \r+\n(?P<result>OK|FAIL)"

last_fail = {"path": None, "line": None}
last_assertion = {}
stats = {"FAIL": 0, "IGNORE": 0, "PASS": 0}
results = []

Expand All @@ -46,13 +48,13 @@ def unity_harness(dut: Dut, ctx: TestContext) -> Optional[TestResult]:
parsed = dut.match.groupdict()

if idx == 0:
if parsed["status"] == "FAIL":
last_fail = parsed
if parsed["status"] in ["FAIL", "IGNORE"]:
last_assertion = parsed
elif idx in (1, 2):
# TODO we do not consider INFO/IGNORE messages
if parsed["status"] == "FAIL":
if last_fail["path"] == parsed["path"] and last_fail["line"] == parsed["line"]:
parsed["msg"] = last_fail["msg"]
# TODO we do not consider INFO messages
if last_assertion and last_assertion["status"] != "INFO":
parsed["msg"] = last_assertion["msg"]
last_assertion = {}

stats[parsed["status"]] += 1
results.append(parsed)
Expand Down
4 changes: 4 additions & 0 deletions unity/unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,11 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
UNITY_OUTPUT_CHAR(' ');
UnityPrint(msg);
}
/* clang-format off */
UNITY_PRINT_EOL();

UNITY_IGNORE_AND_BAIL;
/* clang-format on */
}

/*-----------------------------------------------*/
Expand Down

0 comments on commit 549e819

Please sign in to comment.