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:
commit
d7173e2599
@ -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));
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user