mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
Rename ruff
crate to ruff_linter
(#7529)
This commit is contained in:
parent
dcbd8eacd8
commit
5849a75223
4397 changed files with 93921 additions and 93915 deletions
|
@ -19,7 +19,7 @@ cargo-fuzz = true
|
|||
[dependencies]
|
||||
arbitrary = { version = "1.3.0", features = ["derive"] }
|
||||
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
|
||||
ruff = { path = "../crates/ruff" }
|
||||
ruff_linter = { path = "../crates/ruff_linter" }
|
||||
ruff_python_ast = { path = "../crates/ruff_python_ast" }
|
||||
ruff_python_codegen = { path = "../crates/ruff_python_codegen" }
|
||||
ruff_python_formatter = { path = "../crates/ruff_python_formatter" }
|
||||
|
|
|
@ -98,6 +98,6 @@ fuzzer, but this may be too strict of a restriction for initial testing.
|
|||
### `ruff_fix_validity`
|
||||
|
||||
This fuzz harness checks that fixes applied by Ruff do not introduce new errors using the existing
|
||||
[`ruff::test::test_snippet`](../crates/ruff/src/test.rs) testing utility.
|
||||
[`ruff_linter::test::test_snippet`](../crates/ruff_linter/src/test.rs) testing utility.
|
||||
It currently is only configured to use default settings, but may be extended in future versions to
|
||||
test non-default linter settings.
|
||||
|
|
|
@ -4,22 +4,24 @@
|
|||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||
use ruff::settings::Settings;
|
||||
use ruff_linter::settings::Settings;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
static SETTINGS: OnceLock<Settings> = OnceLock::new();
|
||||
|
||||
fn do_fuzz(case: &[u8]) -> Corpus {
|
||||
// throw away inputs which aren't utf-8
|
||||
let Ok(code) = std::str::from_utf8(case) else { return Corpus::Reject; };
|
||||
let Ok(code) = std::str::from_utf8(case) else {
|
||||
return Corpus::Reject;
|
||||
};
|
||||
|
||||
// the settings are immutable to test_snippet, so we avoid re-initialising here
|
||||
let settings = SETTINGS.get_or_init(Settings::default);
|
||||
ruff::test::set_max_iterations(usize::MAX);
|
||||
ruff_linter::test::set_max_iterations(usize::MAX);
|
||||
|
||||
// unlike in the test framework, where the number of iterations is well-defined, we are only
|
||||
// looking for situations where a fix is bad; thus, we set the iterations to "infinite"
|
||||
let _ = ruff::test::test_snippet(code, settings);
|
||||
let _ = ruff_linter::test::test_snippet(code, settings);
|
||||
|
||||
Corpus::Keep
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ if [ ! -d corpus/ruff_fix_validity ]; then
|
|||
curl -L 'https://zenodo.org/record/3628784/files/python-corpus.tar.gz?download=1' | tar xz
|
||||
fi
|
||||
curl -L 'https://github.com/python/cpython/archive/refs/tags/v3.12.0b2.tar.gz' | tar xz
|
||||
cp -r "../../../crates/ruff/resources/test" .
|
||||
cp -r "../../../crates/ruff_linter/resources/test" .
|
||||
cd -
|
||||
cargo fuzz cmin -s none ruff_fix_validity
|
||||
fi
|
||||
|
|
|
@ -7,7 +7,7 @@ cd "$SCRIPT_DIR"
|
|||
|
||||
cd corpus/ruff_fix_validity
|
||||
curl -L 'https://github.com/python/cpython/archive/refs/tags/v3.12.0b2.tar.gz' | tar xz
|
||||
cp -r "../../../crates/ruff/resources/test" .
|
||||
cp -r "../../../crates/ruff_linter/resources/test" .
|
||||
cd -
|
||||
cargo fuzz cmin -s none ruff_fix_validity
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue