From 549e8192feadc7fae329aef16b2f3bff8a79fdd8 Mon Sep 17 00:00:00 2001 From: Mateusz Bloch Date: Wed, 29 Mar 2023 12:36:23 +0200 Subject: [PATCH] trunner: fix handling TEST_IGNORE_MESSAGE JIRA CI-244 --- trunner/harness/unity.py | 18 ++++++++++-------- unity/unity.c | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/trunner/harness/unity.py b/trunner/harness/unity.py index ba329520..e9e4d9e3 100644 --- a/trunner/harness/unity.py +++ b/trunner/harness/unity.py @@ -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") @@ -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.*?):(?P\d+):(?PFAIL|INFO|IGNORE): (?P.*?)\r" + assert_re = r"ASSERTION (?P[\S]+):(?P\d+):(?PFAIL|INFO|IGNORE): (?P.*?)\r" result_re = r"TEST\((?P\w+), (?P\w+)\) (?PPASS|IGNORE)" # Fail need to have its own regex due to greedy matching result_final_re = r"TEST\((?P\w+), (?P\w+)\) (?PFAIL) at (?P.*?):(?P\d+)\r" final_re = r"(?P\d+) Tests (?P\d+) Failures (?P\d+) Ignored \r+\n(?POK|FAIL)" - last_fail = {"path": None, "line": None} + last_assertion = {} stats = {"FAIL": 0, "IGNORE": 0, "PASS": 0} results = [] @@ -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) diff --git a/unity/unity.c b/unity/unity.c index aa71173a..cec874ad 100644 --- a/unity/unity.c +++ b/unity/unity.c @@ -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 */ } /*-----------------------------------------------*/