aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-14 14:59:19 +0000
committerAleksey Kladov <[email protected]>2020-02-14 15:47:09 +0000
commitce29497e4324d3e2f2c7c696a212672dbdb46884 (patch)
treed75fa5d9994ec174371a16b1d42720833ecda85c /xtask/src/lib.rs
parentbd3a41cc33a25491c19468aaf24dbba4b467edaf (diff)
Replace Cmd with not-bash
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r--xtask/src/lib.rs58
1 files changed, 28 insertions, 30 deletions
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 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3mod cmd; 3pub mod not_bash;
4pub mod install; 4pub mod install;
5pub mod pre_commit; 5pub mod pre_commit;
6 6
@@ -16,8 +16,8 @@ use std::{
16}; 16};
17 17
18use crate::{ 18use crate::{
19 cmd::{run, run_with_output},
20 codegen::Mode, 19 codegen::Mode,
20 not_bash::{pushd, run},
21}; 21};
22 22
23pub use anyhow::Result; 23pub use anyhow::Result;
@@ -38,9 +38,9 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
38 ensure_rustfmt()?; 38 ensure_rustfmt()?;
39 39
40 if mode == Mode::Verify { 40 if mode == Mode::Verify {
41 run(&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), ".")?; 41 run!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN)?;
42 } else { 42 } else {
43 run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?; 43 run!("rustup run {} -- cargo fmt", TOOLCHAIN)?;
44 } 44 }
45 Ok(()) 45 Ok(())
46} 46}
@@ -70,8 +70,9 @@ fn ensure_rustfmt() -> Result<()> {
70 Ok(status) if status.success() => return Ok(()), 70 Ok(status) if status.success() => return Ok(()),
71 _ => (), 71 _ => (),
72 }; 72 };
73 run(&format!("rustup toolchain install {}", TOOLCHAIN), ".")?; 73 run!("rustup toolchain install {}", TOOLCHAIN)?;
74 run(&format!("rustup component add rustfmt --toolchain {}", TOOLCHAIN), ".") 74 run!("rustup component add rustfmt --toolchain {}", TOOLCHAIN)?;
75 Ok(())
75} 76}
76 77
77pub fn run_clippy() -> Result<()> { 78pub fn run_clippy() -> Result<()> {
@@ -92,34 +93,31 @@ pub fn run_clippy() -> Result<()> {
92 "clippy::nonminimal_bool", 93 "clippy::nonminimal_bool",
93 "clippy::redundant_pattern_matching", 94 "clippy::redundant_pattern_matching",
94 ]; 95 ];
95 run( 96 run!(
96 &format!( 97 "rustup run {} -- cargo clippy --all-features --all-targets -- -A {}",
97 "rustup run {} -- cargo clippy --all-features --all-targets -- -A {}", 98 TOOLCHAIN,
98 TOOLCHAIN, 99 allowed_lints.join(" -A ")
99 allowed_lints.join(" -A ")
100 ),
101 ".",
102 )?; 100 )?;
103 Ok(()) 101 Ok(())
104} 102}
105 103
106fn install_clippy() -> Result<()> { 104fn install_clippy() -> Result<()> {
107 run(&format!("rustup toolchain install {}", TOOLCHAIN), ".")?; 105 run!("rustup toolchain install {}", TOOLCHAIN)?;
108 run(&format!("rustup component add clippy --toolchain {}", TOOLCHAIN), ".") 106 run!("rustup component add clippy --toolchain {}", TOOLCHAIN)?;
107 Ok(())
109} 108}
110 109
111pub fn run_fuzzer() -> Result<()> { 110pub fn run_fuzzer() -> Result<()> {
112 match Command::new("cargo") 111 let _d = pushd("./crates/ra_syntax");
113 .args(&["fuzz", "--help"]) 112 match run!("cargo fuzz --help") {
114 .stderr(Stdio::null()) 113 Ok(_) => (),
115 .stdout(Stdio::null()) 114 _ => {
116 .status() 115 run!("cargo install cargo-fuzz")?;
117 { 116 }
118 Ok(status) if status.success() => (),
119 _ => run("cargo install cargo-fuzz", ".")?,
120 }; 117 };
121 118
122 run("rustup run nightly -- cargo fuzz run parser", "./crates/ra_syntax") 119 run!("rustup run nightly -- cargo fuzz run parser")?;
120 Ok(())
123} 121}
124 122
125/// Cleans the `./target` dir after the build such that only 123/// Cleans the `./target` dir after the build such that only
@@ -161,15 +159,15 @@ fn rm_rf(path: &Path) -> Result<()> {
161} 159}
162 160
163pub fn run_release() -> Result<()> { 161pub fn run_release() -> Result<()> {
164 run("git switch release", ".")?; 162 run!("git switch release")?;
165 run("git fetch upstream", ".")?; 163 run!("git fetch upstream")?;
166 run("git reset --hard upstream/master", ".")?; 164 run!("git reset --hard upstream/master")?;
167 run("git push", ".")?; 165 run!("git push")?;
168 166
169 let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts"); 167 let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts");
170 168
171 let today = run_with_output("date --iso", ".")?; 169 let today = run!("date --iso")?;
172 let commit = run_with_output("git rev-parse HEAD", ".")?; 170 let commit = run!("git rev-parse HEAD")?;
173 let changelog_n = fs::read_dir(changelog_dir.as_path())?.count(); 171 let changelog_n = fs::read_dir(changelog_dir.as_path())?.count();
174 172
175 let contents = format!( 173 let contents = format!(