Skip to content

Commit c424007

Browse files
authored
Update usage instructions and lockfile for py-fuzzer script (#20940)
1 parent 0115fd3 commit c424007

File tree

6 files changed

+98
-79
lines changed

6 files changed

+98
-79
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,10 @@ jobs:
498498
chmod +x "${DOWNLOAD_PATH}/ruff"
499499
500500
(
501-
uvx \
501+
uv run \
502502
--python="${PYTHON_VERSION}" \
503-
--from=./python/py-fuzzer \
503+
--project=./python/py-fuzzer \
504+
--locked \
504505
fuzz \
505506
--test-executable="${DOWNLOAD_PATH}/ruff" \
506507
--bin=ruff \
@@ -694,9 +695,10 @@ jobs:
694695
chmod +x "${PWD}/ty" "${NEW_TY}/ty"
695696
696697
(
697-
uvx \
698+
uv run \
698699
--python="${PYTHON_VERSION}" \
699-
--from=./python/py-fuzzer \
700+
--project=./python/py-fuzzer \
701+
--locked \
700702
fuzz \
701703
--test-executable="${NEW_TY}/ty" \
702704
--baseline-executable="${PWD}/ty" \

.github/workflows/daily_fuzz.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ jobs:
4848
run: |
4949
# shellcheck disable=SC2046
5050
(
51-
uvx \
52-
--python=3.12 \
53-
--from=./python/py-fuzzer \
51+
uv run \
52+
--python=3.13 \
53+
--project=./python/py-fuzzer \
54+
--locked \
5455
fuzz \
5556
--test-executable=target/debug/ruff \
5657
--bin=ruff \

crates/ruff_python_parser/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To run the fuzzer, execute the following command
6262
(requires [`uv`](https://github.com/astral-sh/uv) to be installed):
6363

6464
```sh
65-
uvx --from ./python/py-fuzzer fuzz
65+
uv run --project=./python/py-fuzzer fuzz
6666
```
6767

6868
Refer to the [py-fuzzer](https://github.com/astral-sh/ruff/blob/main/python/py-fuzzer/fuzz.py)

python/py-fuzzer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
A fuzzer script to run Ruff executables on randomly generated
44
(but syntactically valid) Python source-code files.
55

6-
Run `uvx --from ./python/py-fuzzer fuzz -h` from the repository root
6+
Run `uv run --project=./python/py-fuzzer fuzz -h` from the repository root
77
for more information and example invocations
88
(requires [`uv`](https://github.com/astral-sh/uv) to be installed).

python/py-fuzzer/fuzz.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44
55
This script can be installed into a virtual environment using
66
`uv pip install -e ./python/py-fuzzer` from the Ruff repository root,
7-
or can be run using `uvx --from ./python/py-fuzzer fuzz`
7+
or can be run using `uv run --project=./python/py-fuzzer fuzz`
88
(in which case the virtual environment does not need to be activated).
9+
Note that using `uv run --project` rather than `uvx --from` means that
10+
uv will respect the script's lockfile.
911
1012
Example invocations of the script using `uv`:
1113
- Run the fuzzer on Ruff's parser using seeds 0, 1, 2, 78 and 93 to generate the code:
12-
`uvx --from ./python/py-fuzzer fuzz --bin ruff 0-2 78 93`
14+
`uv run --project=./python/py-fuzzer fuzz --bin ruff 0-2 78 93`
1315
- Run the fuzzer concurrently using seeds in range 0-10 inclusive,
1416
but only reporting bugs that are new on your branch:
15-
`uvx --from ./python/py-fuzzer fuzz --bin ruff 0-10 --only-new-bugs`
17+
`uv run --project=./python/py-fuzzer fuzz --bin ruff 0-10 --only-new-bugs`
1618
- Run the fuzzer concurrently on 10,000 different Python source-code files,
1719
using a random selection of seeds, and only print a summary at the end
1820
(the `shuf` command is Unix-specific):
19-
`uvx --from ./python/py-fuzzer fuzz --bin ruff $(shuf -i 0-1000000 -n 10000) --quiet
20-
21-
If you make local modifications to this script, you'll need to run the above
22-
with `--reinstall` to get your changes reflected in the uv-cached installed
23-
package. Alternatively, if iterating quickly on changes, you can add
24-
`--with-editable ./python/py-fuzzer`.
21+
`uv run --project=./python/py-fuzzer fuzz --bin ruff $(shuf -i 0-1000000 -n 10000) --quiet
2522
"""
2623

2724
from __future__ import annotations

0 commit comments

Comments
 (0)