Auto merge of #10747 - Alexendoo:cargo-dev-dogfood-stdout, r=flip1995

Inherit stdout/stderr for `cargo dev dogfood`

changelog: none

Prints progress as it happens and in colour, and will also show anything printed to stderr
This commit is contained in:
bors 2023-05-05 12:22:25 +00:00
commit d7173e2599
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;
/// # Panics
@ -10,7 +10,7 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
cmd.current_dir(clippy_project_root())
.args(["test", "--test", "dogfood"])
.args(["--features", "internal"])
.args(["--", "dogfood_clippy"]);
.args(["--", "dogfood_clippy", "--nocapture"]);
let mut dogfood_args = Vec::new();
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(" "));
let output = cmd.output().expect("failed to run command");
println!("{}", String::from_utf8_lossy(&output.stdout));
exit_if_err(cmd.status());
}

View File

@ -10,7 +10,9 @@
extern crate rustc_driver;
extern crate rustc_lexer;
use std::io;
use std::path::PathBuf;
use std::process::{self, ExitStatus};
pub mod bless;
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.");
}
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 std::process::{self, Command, ExitStatus};
use std::{fs, io};
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);
},
}
}
use crate::{cargo_clippy_path, exit_if_err};
use std::fs;
use std::process::{self, Command};
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
let is_file = match fs::metadata(path) {