]> git.lizzy.rs Git - rust.git/blobdiff - crates/tools/src/lib.rs
Use stable toolchain
[rust.git] / crates / tools / src / lib.rs
index 2795afe0b6cad12afb796c9895982943395f2e0c..d404db2144ca4732486bbdd2b417b2a258e43d52 100644 (file)
@@ -15,7 +15,7 @@
 pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron";
 pub const SYNTAX_KINDS: &str = "crates/ra_syntax/src/syntax_kinds/generated.rs.tera";
 pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs.tera";
-const TOOLCHAIN: &str = "1.31.1";
+const TOOLCHAIN: &str = "stable";
 
 #[derive(Debug)]
 pub struct Test {
@@ -29,7 +29,7 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
     let prefix = "// ";
     let comment_blocks = s
         .lines()
-        .map(str::trim_left)
+        .map(str::trim_start)
         .enumerate()
         .group_by(|(_idx, line)| line.starts_with(prefix));
 
@@ -117,7 +117,7 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
     Ok(())
 }
 
-fn install_rustfmt() -> Result<()> {
+pub fn install_rustfmt() -> Result<()> {
     run(&format!("rustup install {}", TOOLCHAIN), ".")?;
     run(
         &format!("rustup component add rustfmt --toolchain {}", TOOLCHAIN),
@@ -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",
+    )
+}