Skip to content

Commit

Permalink
(hw-results/tabular) nicer macros, use longtable
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner committed May 20, 2024
1 parent 4112b0c commit 247d4c4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions hw-results/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,14 @@ def filter_devices(grp_list, devices: "Mapping[Device, List[LogFileResult]]", in

return tests

def macro_test_name(test):
sanitized_name = (
test.test_name
.replace("_", "\\_")
.replace("&", "\\&")
)
return f"\\tableTestName{{{test.test_name}}}{{{sanitized_name}}}"

def macro_result_name(device, test):
return f"\\csname {device.name}-{test.test_name} result\\endcsname"

Expand Down Expand Up @@ -646,7 +654,7 @@ def _write_combo_tablular_with_distribution(f, devices, tests, rows):
tab_shape += "l "
tab_shape += device_cols_ls
tab_shape += " l"
f.write("\\begin{tabular}{%s}\n" % tab_shape)
f.write("\\begin{longtable}{%s}\n" % tab_shape)

# first line
#  Type & Name & multicol{3}{rpi4} & multicol{3}{qemu} & etc
Expand Down Expand Up @@ -674,7 +682,7 @@ def _write_combo_tablular_with_distribution(f, devices, tests, rows):
continue
f.write(f"{c!s:>{maxlen}} & ")
f.write("\\\\ \\hline \n")
f.write("\\end{tabular}\n")
f.write("\\end{longtable}\n")

def _write_combo_tablular_simple(f, devices, tests, rows):
all_groups = set(g for ftest in tests.values() for g in ftest.groups if g != "all")
Expand All @@ -696,7 +704,7 @@ def _write_combo_tablular_simple(f, devices, tests, rows):
tab_shape += device_cols_ls
tab_shape += " l"

f.write("\\begin{tabular}{%s}\n" % tab_shape)
f.write("\\begin{longtable}{%s}\n" % tab_shape)

# first line
#  Type & Name & multicol{3}{rpi4} & multicol{3}{qemu} & etc
Expand All @@ -716,7 +724,7 @@ def _write_combo_tablular_simple(f, devices, tests, rows):
continue
f.write(f"{c!s} & ")
f.write("\\\\ \\hline \n")
f.write("\\end{tabular}\n")
f.write("\\end{longtable}\n")


# def write_results_macros(f, devices, tests):
Expand Down Expand Up @@ -747,7 +755,10 @@ def write_combo_table(f, devices: "Mapping[Device, List[LogFileResult]]", tests,
group = groups[-1]
# use verb to escape test and group names with symbols
row.append(f"\\verb|{group}|")
row.append(f"\\verb|{test_name}|")
if args.macros:
row.append(macro_test_name(ftest))
else:
row.append(f"\\verb|{test_name}|")

for d in devices:
flog = tests[test_name].results[d]
Expand Down Expand Up @@ -861,6 +872,7 @@ def main(args):
with open(args.standalone_file, "w") as f:
f.write("\\documentclass{standalone}\n")
f.write("\\begin{document}\n")
f.write("\\usepackage{longtable}\n")

if args.macros:
write_results_macros(f, devices, filtered_tests)
Expand Down

0 comments on commit 247d4c4

Please sign in to comment.