aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r--xtask/src/lib.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index bae4c4650..bfee2f9c8 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -2,10 +2,10 @@
2 2
3pub mod codegen; 3pub mod codegen;
4 4
5use anyhow::Context;
6pub use anyhow::Result;
5use std::{ 7use std::{
6 env, 8 env, fs,
7 error::Error,
8 fs,
9 io::{Error as IoError, ErrorKind}, 9 io::{Error as IoError, ErrorKind},
10 path::{Path, PathBuf}, 10 path::{Path, PathBuf},
11 process::{Command, Output, Stdio}, 11 process::{Command, Output, Stdio},
@@ -13,8 +13,6 @@ use std::{
13 13
14use crate::codegen::Mode; 14use crate::codegen::Mode;
15 15
16pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
17
18const TOOLCHAIN: &str = "stable"; 16const TOOLCHAIN: &str = "stable";
19 17
20pub fn project_root() -> PathBuf { 18pub fn project_root() -> PathBuf {
@@ -69,7 +67,7 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
69 .status() 67 .status()
70 { 68 {
71 Ok(status) if status.success() => (), 69 Ok(status) if status.success() => (),
72 _ => install_rustfmt()?, 70 _ => install_rustfmt().context("install rustfmt")?,
73 }; 71 };
74 72
75 if mode == Mode::Verify { 73 if mode == Mode::Verify {
@@ -112,7 +110,7 @@ pub fn run_clippy() -> Result<()> {
112 .status() 110 .status()
113 { 111 {
114 Ok(status) if status.success() => (), 112 Ok(status) if status.success() => (),
115 _ => install_clippy()?, 113 _ => install_clippy().context("install clippy")?,
116 }; 114 };
117 115
118 let allowed_lints = [ 116 let allowed_lints = [
@@ -162,9 +160,9 @@ where
162 let exec = args.next().unwrap(); 160 let exec = args.next().unwrap();
163 let mut cmd = Command::new(exec); 161 let mut cmd = Command::new(exec);
164 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit())); 162 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit()));
165 let output = cmd.output()?; 163 let output = cmd.output().with_context(|| format!("running `{}`", cmdline))?;
166 if !output.status.success() { 164 if !output.status.success() {
167 Err(format!("`{}` exited with {}", cmdline, output.status))?; 165 anyhow::bail!("`{}` exited with {}", cmdline, output.status);
168 } 166 }
169 Ok(output) 167 Ok(output)
170} 168}