From ce29497e4324d3e2f2c7c696a212672dbdb46884 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Feb 2020 15:59:19 +0100 Subject: Replace Cmd with not-bash --- xtask/src/lib.rs | 58 +++++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'xtask/src/lib.rs') diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 1bb1882b0..d2ef2e95b 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -mod cmd; +pub mod not_bash; pub mod install; pub mod pre_commit; @@ -16,8 +16,8 @@ use std::{ }; use crate::{ - cmd::{run, run_with_output}, codegen::Mode, + not_bash::{pushd, run}, }; pub use anyhow::Result; @@ -38,9 +38,9 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> { ensure_rustfmt()?; if mode == Mode::Verify { - run(&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), ".")?; + run!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN)?; } else { - run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?; + run!("rustup run {} -- cargo fmt", TOOLCHAIN)?; } Ok(()) } @@ -70,8 +70,9 @@ fn ensure_rustfmt() -> Result<()> { Ok(status) if status.success() => return Ok(()), _ => (), }; - run(&format!("rustup toolchain install {}", TOOLCHAIN), ".")?; - run(&format!("rustup component add rustfmt --toolchain {}", TOOLCHAIN), ".") + run!("rustup toolchain install {}", TOOLCHAIN)?; + run!("rustup component add rustfmt --toolchain {}", TOOLCHAIN)?; + Ok(()) } pub fn run_clippy() -> Result<()> { @@ -92,34 +93,31 @@ pub fn run_clippy() -> Result<()> { "clippy::nonminimal_bool", "clippy::redundant_pattern_matching", ]; - run( - &format!( - "rustup run {} -- cargo clippy --all-features --all-targets -- -A {}", - TOOLCHAIN, - allowed_lints.join(" -A ") - ), - ".", + run!( + "rustup run {} -- cargo clippy --all-features --all-targets -- -A {}", + TOOLCHAIN, + allowed_lints.join(" -A ") )?; Ok(()) } fn install_clippy() -> Result<()> { - run(&format!("rustup toolchain install {}", TOOLCHAIN), ".")?; - run(&format!("rustup component add clippy --toolchain {}", TOOLCHAIN), ".") + run!("rustup toolchain install {}", TOOLCHAIN)?; + run!("rustup component add clippy --toolchain {}", TOOLCHAIN)?; + 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", ".")?, + let _d = pushd("./crates/ra_syntax"); + match run!("cargo fuzz --help") { + Ok(_) => (), + _ => { + run!("cargo install cargo-fuzz")?; + } }; - run("rustup run nightly -- cargo fuzz run parser", "./crates/ra_syntax") + run!("rustup run nightly -- cargo fuzz run parser")?; + Ok(()) } /// Cleans the `./target` dir after the build such that only @@ -161,15 +159,15 @@ fn rm_rf(path: &Path) -> Result<()> { } pub fn run_release() -> Result<()> { - run("git switch release", ".")?; - run("git fetch upstream", ".")?; - run("git reset --hard upstream/master", ".")?; - run("git push", ".")?; + run!("git switch release")?; + run!("git fetch upstream")?; + run!("git reset --hard upstream/master")?; + run!("git push")?; let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts"); - let today = run_with_output("date --iso", ".")?; - let commit = run_with_output("git rev-parse HEAD", ".")?; + let today = run!("date --iso")?; + let commit = run!("git rev-parse HEAD")?; let changelog_n = fs::read_dir(changelog_dir.as_path())?.count(); let contents = format!( -- cgit v1.2.3