py-fuzzer: allow relative executable paths (#18915)

## 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.
This commit is contained in:
David Peter 2025-06-24 15:16:21 +02:00 committed by GitHub
parent 833be2e66a
commit 0edbd6c390
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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",