Skip to content

Commit

Permalink
Merge pull request #3187 from heplesser/fix-3155
Browse files Browse the repository at this point in the history
Make test log parsing robust
  • Loading branch information
terhorstd authored Jun 5, 2024
2 parents 64da939 + 56133b5 commit bf55cc4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions testsuite/summarize_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@


def parse_result_file(fname):
results = jp.JUnitXml.fromfile(fname)
try:
results = jp.JUnitXml.fromfile(fname)
except Exception as err:
return {
"Tests": 1,
"Skipped": 0,
"Failures": 0,
"Errors": 1,
"Time": 0,
"Failed tests": [f"ERROR: XML file {fname} not parsable with error {err}"],
}

if isinstance(results, jp.junitparser.JUnitXml):
# special case for pytest, which wraps all once more
suites = list(results)
Expand Down Expand Up @@ -119,15 +130,17 @@ def parse_result_file(fname):
print(tline)
print()

# Second condition handles xml parsing failures
if totals["Failures"] + totals["Errors"] > 0 or totals["Failed tests"]:
# Consistency check
assert totals["Failures"] + totals["Errors"] == len(totals["Failed tests"])

if totals["Failures"] + totals["Errors"] > 0:
print("THE NEST TESTSUITE DISCOVERED PROBLEMS")
print(" The following tests failed")
for t in totals["Failed tests"]:
print(f" | {t}") # | marks line for parsing
print()
print(" Please report test failures by creating an issue at")
print(" https://github.com/nest/nest_simulator/issues")
print(" https://github.com/nest/nest-simulator/issues")
print()
print(tline)
print()
Expand Down

0 comments on commit bf55cc4

Please sign in to comment.