Replace Cmd with not-bash

This commit is contained in:
Aleksey Kladov 2020-02-14 15:59:19 +01:00
parent bd3a41cc33
commit ce29497e43
5 changed files with 173 additions and 156 deletions

View file

@ -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!(