From 0edbd6c390a16677a1214a29f835444a1d522172 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 24 Jun 2025 15:16:21 +0200 Subject: [PATCH] py-fuzzer: allow relative executable paths (#18915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary I tried running `py-fuzzer` using executables in the current working directory, but that failed with: ``` ▶ uvx --from ./python/py-fuzzer --reinstall fuzz --test-executable ./ty_feature --bin=ty --baseline-executable ./ty_main --only-new-bugs 0-500 Usage: fuzz [-h] [--only-new-bugs] [--quiet] [--test-executable TEST_EXECUTABLE] [--baseline-executable BASELINE_EXECUTABLE] --bin {ruff,ty} seeds [seeds ...] fuzz: error: Bad argument passed to `--baseline-executable`: no such file or executable PosixPath('ty_main') "Bad argument passed to `--baseline-executable`: no such file or executable PosixPath('ty_main')" ``` Using `.absolute()` on the `Path` fixes this. ## Test Plan Successful `py-fuzzer` run with the invocation above. --- python/py-fuzzer/fuzz.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/py-fuzzer/fuzz.py b/python/py-fuzzer/fuzz.py index 3b3c3f0423..7735bef15c 100644 --- a/python/py-fuzzer/fuzz.py +++ b/python/py-fuzzer/fuzz.py @@ -268,6 +268,10 @@ def run_fuzzer(args: ResolvedCliArgs) -> ExitCode: return ExitCode(0) +def absolute_path(p: str) -> Path: + return Path(p).absolute() + + def parse_seed_argument(arg: str) -> int | range: """Helper for argument parsing""" if "-" in arg: @@ -337,7 +341,7 @@ def parse_args() -> ResolvedCliArgs: "Executable to test. " "Defaults to a fresh build of the currently checked-out branch." ), - type=Path, + type=absolute_path, ) parser.add_argument( "--baseline-executable", @@ -346,7 +350,7 @@ def parse_args() -> ResolvedCliArgs: "Defaults to whatever version is installed " "in the Python environment." ), - type=Path, + type=absolute_path, ) parser.add_argument( "--bin",