-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] Add fuzzer to catch panics for invalid syntax #14678
Conversation
aa40db7
to
94698f8
Compare
94698f8
to
4df8284
Compare
|
cp -r "../../../crates/ruff_python_parser/resources" "ruff_python_parser" | ||
|
||
# Delete all non-Python files | ||
find . -type f -not -name "*.py" -delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also keep stub files?
Using
find . -type f -not -name "*.py" -delete | |
find . -type f -not \( -name "*.py" -or -name "*.pyi" \) -delete |
or
find . -type f -not -name "*.py" -delete | |
find . -type f -not -regex '.*\.pyi?' -delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could but at the end we would still use a .py
file even if the content is coming from a stub file. The reason is that the fuzzer gives us the raw bytes of the source code that it generates.
Hmm, maybe we should run red knot once on a .py
file and then on a .pyi
file with the same content as we do on the corpus tests.
* main: [red-knot] Test: Hashable/Sized => A/B (#14769) [`flake8-type-checking`] Expands TC006 docs to better explain itself (#14749) [`pycodestyle`] Handle f-strings properly for `invalid-escape-sequence (W605)` (#14748) [red-knot] Add fuzzer to catch panics for invalid syntax (#14678) Check `AIR001` from builtin or providers `operators` module (#14631) [airflow]: extend removed names (AIR302) (#14734)
Summary
This PR adds a fuzzer harness for red knot that runs the type checker on source code that contains invalid syntax.
Additionally, this PR also updates the
init-fuzzer.sh
script to increase the corpus size to:And, remove any non-Python files from the final corpus so that when the fuzzer tries to minify the corpus, it doesn't produce files that only contains documentation content as that's just noise.
Test Plan
Run
./fuzz/init-fuzzer.sh
, say no to the large dataset.Run the fuzzer with
cargo +night fuzz run red_knot_check_invalid_syntax -- -timeout=5