Skip to content

Commit 1abdfd1

Browse files
committed
Keep a failed summary write from failing the benchmark
1 parent 63a998a commit 1abdfd1

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

toolchain/mfc/bench.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def bench(targets=None):
193193
cons.unindent()
194194

195195

196-
def _write_step_summary(lhs_path: str, rhs_path: str, rows: list, warnings: list):
196+
def _write_step_summary(lhs_path: str, rhs_path: str, rows: typing.List[typing.Tuple[str, str, str, str]], warnings: typing.List[str]):
197197
"""Put the speedup table on the workflow run's summary page.
198198
199199
The same numbers already go to stdout, but reading them there means expanding the
@@ -222,8 +222,14 @@ def _write_step_summary(lhs_path: str, rhs_path: str, rows: list, warnings: list
222222
lines += ["", "**Below threshold**", ""] + [f"- {w}" for w in warnings]
223223
lines.append("")
224224

225-
with open(path, "a", encoding="utf-8") as f:
226-
f.write("\n".join(lines))
225+
# The summary is a convenience on top of output that already went to stdout, so a filesystem
226+
# problem here must not fail a benchmark that otherwise succeeded. Narrow to OSError: anything
227+
# else is a bug in the lines above and should surface.
228+
try:
229+
with open(path, "a", encoding="utf-8") as f:
230+
f.write("\n".join(lines))
231+
except OSError as exc:
232+
cons.print(f"[bold yellow]Warning[/bold yellow]: could not write the benchmark step summary: {exc}")
227233

228234

229235
def diff():

0 commit comments

Comments
 (0)