Skip to content

Commit

Permalink
Merge pull request #3129 from heplesser/fix-test-report-format
Browse files Browse the repository at this point in the history
Automatically adjust column widths in testsuite report
  • Loading branch information
terhorstd authored Mar 12, 2024
2 parents 4129e9a + 3f8d6e9 commit 8dd4b52
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions testsuite/summarize_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,36 @@ def parse_result_file(fname):
totals[k] += v

cols = ["Tests", "Skipped", "Failures", "Errors", "Time"]
tline = "-" * (len(cols) * 10 + 20)

col_w = max(len(c) for c in cols) + 2
first_col_w = max(len(k) for k in results.keys())

tline = "-" * (len(cols) * col_w + first_col_w)

print()
print()
print(tline)
print("NEST Testsuite Results")

print(tline)
print("{:<20s}".format("Phase"), end="")
print(f"{'Phase':<{first_col_w}s}", end="")
for c in cols:
print("{:>10s}".format(c), end="")
print(f"{c:>{col_w}s}", end="")
print()

print(tline)
for pn, pr in results.items():
print("{:<20s}".format(pn), end="")
print(f"{pn:<{first_col_w}s}", end="")
for c in cols:
fstr = "{:10.1f}" if c == "Time" else "{:10d}"
print(fstr.format(pr[c]), end="")
fmt = ".1f" if c == "Time" else "d"
print(f"{pr[c]:{col_w}{fmt}}", end="")
print()

print(tline)
print("{:<20s}".format("Total"), end="")
print(f"{'Total':<{first_col_w}s}", end="")
for c in cols:
fstr = "{:10.1f}" if c == "Time" else "{:10d}"
print(fstr.format(totals[c]), end="")
fmt = ".1f" if c == "Time" else "d"
print(f"{totals[c]:{col_w}{fmt}}", end="")
print()
print(tline)
print()
Expand Down

0 comments on commit 8dd4b52

Please sign in to comment.