From f61830d6768ecb0d2a9c5f4c80ed9c561c9daa6f Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Mon, 31 Dec 2018 13:14:06 +0000 Subject: Add a fuzzing subcommand --- crates/tools/src/lib.rs | 17 +++++++++++++++++ crates/tools/src/main.rs | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index e5b32c25c..fa619af33 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -139,3 +139,20 @@ pub fn install_format_hook() -> Result<()> { } 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", + ) +} diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 7edf8f52d..9d73d57c4 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs @@ -7,7 +7,10 @@ use std::{ use clap::{App, Arg, SubCommand}; 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 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("format")) .subcommand(SubCommand::with_name("format-hook")) + .subcommand(SubCommand::with_name("fuzz-tests")) .get_matches(); let mode = if matches.is_present("verify") { Verify @@ -42,6 +46,7 @@ fn main() -> Result<()> { "gen-syntax" => generate(Overwrite)?, "format" => run_rustfmt(mode)?, "format-hook" => install_format_hook()?, + "fuzz-tests" => run_fuzzer()?, _ => unreachable!(), } Ok(()) -- cgit v1.2.3