mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Add a fuzzing subcommand
This commit is contained in:
parent
81acdafc51
commit
f61830d676
3 changed files with 35 additions and 7 deletions
|
@ -1,10 +1,16 @@
|
||||||
[alias]
|
[alias]
|
||||||
# Automatically generates the ast and syntax kinds files
|
# Automatically generates the ast and syntax kinds files
|
||||||
gen-syntax = "run --package tools --bin tools -- gen-syntax"
|
gen-syntax = "run --package tools --bin tools -- gen-syntax"
|
||||||
|
# Extracts the tests from
|
||||||
gen-tests = "run --package tools --bin tools -- gen-tests"
|
gen-tests = "run --package tools --bin tools -- gen-tests"
|
||||||
|
# Installs the visual studio code extension
|
||||||
install-code = "run --package tools --bin tools -- install-code"
|
install-code = "run --package tools --bin tools -- install-code"
|
||||||
|
# Formats the full repository or installs the git hook to do it automatically.
|
||||||
format = "run --package tools --bin tools -- format"
|
format = "run --package tools --bin tools -- format"
|
||||||
format-hook = "run --package tools --bin tools -- format-hook"
|
format-hook = "run --package tools --bin tools -- format-hook"
|
||||||
|
# Runs the fuzzing test suite (currently only parser)
|
||||||
|
fuzz-tests = "run --package tools --bin tools -- fuzz-tests"
|
||||||
|
|
||||||
render-test = "run --package ra_cli -- render-test"
|
render-test = "run --package ra_cli -- render-test"
|
||||||
|
# Parse a file. This should be piped the file contents
|
||||||
parse = "run --package ra_cli -- parse"
|
parse = "run --package ra_cli -- parse"
|
||||||
|
|
|
@ -139,3 +139,20 @@ pub fn install_format_hook() -> Result<()> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_fuzzer() -> Result<()> {
|
||||||
|
match Command::new("cargo")
|
||||||
|
.args(&["fuzz", "--help"])
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.status()
|
||||||
|
{
|
||||||
|
Ok(status) if status.success() => (),
|
||||||
|
_ => run("cargo install cargo-fuzz", ".")?,
|
||||||
|
};
|
||||||
|
|
||||||
|
run(
|
||||||
|
"rustup run nightly -- cargo fuzz run parser",
|
||||||
|
"./crates/ra_syntax",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@ use std::{
|
||||||
use clap::{App, Arg, SubCommand};
|
use clap::{App, Arg, SubCommand};
|
||||||
use failure::bail;
|
use failure::bail;
|
||||||
|
|
||||||
use tools::{collect_tests, generate, install_format_hook, run, run_rustfmt, Mode, Overwrite, Result, Test, Verify, project_root};
|
use tools::{
|
||||||
|
collect_tests, generate,install_format_hook, run, run_rustfmt,
|
||||||
|
Mode, Overwrite, Result, Test, Verify, project_root, run_fuzzer
|
||||||
|
};
|
||||||
|
|
||||||
const GRAMMAR_DIR: &str = "crates/ra_syntax/src/grammar";
|
const GRAMMAR_DIR: &str = "crates/ra_syntax/src/grammar";
|
||||||
const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/ok";
|
const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/ok";
|
||||||
|
@ -27,6 +30,7 @@ fn main() -> Result<()> {
|
||||||
.subcommand(SubCommand::with_name("install-code"))
|
.subcommand(SubCommand::with_name("install-code"))
|
||||||
.subcommand(SubCommand::with_name("format"))
|
.subcommand(SubCommand::with_name("format"))
|
||||||
.subcommand(SubCommand::with_name("format-hook"))
|
.subcommand(SubCommand::with_name("format-hook"))
|
||||||
|
.subcommand(SubCommand::with_name("fuzz-tests"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
let mode = if matches.is_present("verify") {
|
let mode = if matches.is_present("verify") {
|
||||||
Verify
|
Verify
|
||||||
|
@ -42,6 +46,7 @@ fn main() -> Result<()> {
|
||||||
"gen-syntax" => generate(Overwrite)?,
|
"gen-syntax" => generate(Overwrite)?,
|
||||||
"format" => run_rustfmt(mode)?,
|
"format" => run_rustfmt(mode)?,
|
||||||
"format-hook" => install_format_hook()?,
|
"format-hook" => install_format_hook()?,
|
||||||
|
"fuzz-tests" => run_fuzzer()?,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue