Inherit stdout/stderr for cargo dev dogfood

This commit is contained in:
Alex Macleod 2023-05-05 11:45:24 +00:00
parent f9c1d155b4
commit 0f7b61d729
3 changed files with 19 additions and 19 deletions

View File

@ -1,4 +1,4 @@
use crate::clippy_project_root; use crate::{clippy_project_root, exit_if_err};
use std::process::Command; use std::process::Command;
/// # Panics /// # Panics
@ -10,7 +10,7 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
cmd.current_dir(clippy_project_root()) cmd.current_dir(clippy_project_root())
.args(["test", "--test", "dogfood"]) .args(["test", "--test", "dogfood"])
.args(["--features", "internal"]) .args(["--features", "internal"])
.args(["--", "dogfood_clippy"]); .args(["--", "dogfood_clippy", "--nocapture"]);
let mut dogfood_args = Vec::new(); let mut dogfood_args = Vec::new();
if fix { if fix {
@ -27,7 +27,5 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" ")); cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" "));
let output = cmd.output().expect("failed to run command"); exit_if_err(cmd.status());
println!("{}", String::from_utf8_lossy(&output.stdout));
} }

View File

@ -10,7 +10,9 @@
extern crate rustc_driver; extern crate rustc_driver;
extern crate rustc_lexer; extern crate rustc_lexer;
use std::io;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{self, ExitStatus};
pub mod bless; pub mod bless;
pub mod dogfood; pub mod dogfood;
@ -58,3 +60,14 @@ pub fn clippy_project_root() -> PathBuf {
} }
panic!("error: Can't determine root of project. Please run inside a Clippy working dir."); panic!("error: Can't determine root of project. Please run inside a Clippy working dir.");
} }
pub fn exit_if_err(status: io::Result<ExitStatus>) {
match status.expect("failed to run command").code() {
Some(0) => {},
Some(n) => process::exit(n),
None => {
eprintln!("Killed by signal");
process::exit(1);
},
}
}

View File

@ -1,17 +1,6 @@
use crate::cargo_clippy_path; use crate::{cargo_clippy_path, exit_if_err};
use std::process::{self, Command, ExitStatus}; use std::fs;
use std::{fs, io}; use std::process::{self, Command};
fn exit_if_err(status: io::Result<ExitStatus>) {
match status.expect("failed to run command").code() {
Some(0) => {},
Some(n) => process::exit(n),
None => {
eprintln!("Killed by signal");
process::exit(1);
},
}
}
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) { pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
let is_file = match fs::metadata(path) { let is_file = match fs::metadata(path) {