Skip to content

Commit 52d9548

Browse files
committed
Display specific failing cocotb testcases
1 parent 411be65 commit 52d9548

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ reports:
9393
image: python:3.10
9494

9595
script:
96-
- pip install "psycopg>=3"
96+
- pip install junitparser "psycopg>=3"
9797
- ./tools/ci/save_build_stats.py
9898

9999

tools/ci/build_stats.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@
7979
{% if build.sim.result == "pass" %}
8080
<td style="text-align: center" class="success">PASS</td>
8181
{% elif build.sim.result == "fail" %}
82-
<td style="text-align: center" class="error">FAIL</td>
82+
<td style="text-align: center" class="error">
83+
{% if build.sim.failed_testcases | default(None) %}
84+
<abbr title="Failed testcases:&#x0A;{{ build.sim.failed_testcases | join("\n") }}">FAIL</abbr>
85+
{% else %}
86+
FAIL
87+
{% endif %}
88+
</td>
8389
{% else %}
8490
<td style="text-align: center">?</td>
8591
{% endif %}

tools/ci/save_build_stats.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
import os
1919

20+
from junitparser import JUnitXml
2021
import psycopg
2122

2223

@@ -30,17 +31,27 @@
3031

3132
# Results of simulation
3233

33-
try:
34-
with open("results.xml", "rt") as f:
35-
xml = f.read()
34+
if os.path.exists("results.xml"): # ugh. fromfile() raises generic OSError
35+
# instead of FileNotFoundError
36+
xml = JUnitXml.fromfile("results.xml")
37+
38+
failures = []
39+
40+
for suite in xml:
41+
for case in suite:
42+
if any(r._tag == "failure" for r in case.result):
43+
logger.info("%s:%s FAIL", case.classname, case.name)
44+
failures.append(case.classname + ":" + case.name)
45+
else:
46+
logger.info("%s:%s PASS", case.classname, case.name)
3647

37-
if "<failure" not in xml:
48+
if len(failures) > 0:
49+
logger.info("cocotb FAIL")
50+
results["sim"] = dict(result="fail", failed_testcases=failures)
51+
else:
3852
logger.info("cocotb PASS")
3953
results["sim"] = dict(result="pass")
40-
else:
41-
logger.info("cocotb FAIL")
42-
results["sim"] = dict(result="fail")
43-
except FileNotFoundError:
54+
else:
4455
logger.error("results.xml not found")
4556
results["sim"] = dict(result=None)
4657

0 commit comments

Comments
 (0)