From 4baba0225860556db8bae905b574be3cfd7209e7 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 6 Nov 2026 13:16:32 -0800 Subject: [PATCH] Sanitize slashes in benchmark result filenames --- bench_runner/result.py | 4 ++-- tests/test_result.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bench_runner/result.py b/bench_runner/result.py index f561126a..240c5cbc 100644 --- a/bench_runner/result.py +++ b/bench_runner/result.py @@ -48,9 +48,9 @@ def _clean(string: str) -> str: """ Clean an arbitrary string to be suitable for a filename. - It can't contain dashes, since dashes are used as a delimiter. + Dashes delimit filename fields, and slashes would create subdirectories. """ - return string.replace("-", "_") + return string.replace("-", "_").replace("/", "_") def _clean_for_url(string: str) -> str: diff --git a/tests/test_result.py b/tests/test_result.py index d878b79e..ecdcd126 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -122,3 +122,7 @@ def gethostname(*args): f"bm-20221119-{platform.system().lower()}-{platform.machine().lower()}" f"-my%2dfork-9d38120e335357a3b294-{platform.python_version()}-b7e4f1d.json" ) + + result = mod_result.Result.from_scratch(python, "my-fork", "jit/free-threading") + assert result.ref == "jit_free_threading" + assert result.filename.parent.parent == Path("results")