Skip to content

Commit d7173e2

Browse files
committed
Auto merge of rust-lang#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
2 parents f9c1d15 + 0f7b61d commit d7173e2

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

clippy_dev/src/dogfood.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::clippy_project_root;
1+
use crate::{clippy_project_root, exit_if_err};
22
use std::process::Command;
33

44
/// # Panics
@@ -10,7 +10,7 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
1010
cmd.current_dir(clippy_project_root())
1111
.args(["test", "--test", "dogfood"])
1212
.args(["--features", "internal"])
13-
.args(["--", "dogfood_clippy"]);
13+
.args(["--", "dogfood_clippy", "--nocapture"]);
1414

1515
let mut dogfood_args = Vec::new();
1616
if fix {
@@ -27,7 +27,5 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
2727

2828
cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" "));
2929

30-
let output = cmd.output().expect("failed to run command");
31-
32-
println!("{}", String::from_utf8_lossy(&output.stdout));
30+
exit_if_err(cmd.status());
3331
}

clippy_dev/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
extern crate rustc_driver;
1111
extern crate rustc_lexer;
1212

13+
use std::io;
1314
use std::path::PathBuf;
15+
use std::process::{self, ExitStatus};
1416

1517
pub mod bless;
1618
pub mod dogfood;
@@ -58,3 +60,14 @@ pub fn clippy_project_root() -> PathBuf {
5860
}
5961
panic!("error: Can't determine root of project. Please run inside a Clippy working dir.");
6062
}
63+
64+
pub fn exit_if_err(status: io::Result<ExitStatus>) {
65+
match status.expect("failed to run command").code() {
66+
Some(0) => {},
67+
Some(n) => process::exit(n),
68+
None => {
69+
eprintln!("Killed by signal");
70+
process::exit(1);
71+
},
72+
}
73+
}

clippy_dev/src/lint.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
use crate::cargo_clippy_path;
2-
use std::process::{self, Command, ExitStatus};
3-
use std::{fs, io};
4-
5-
fn exit_if_err(status: io::Result<ExitStatus>) {
6-
match status.expect("failed to run command").code() {
7-
Some(0) => {},
8-
Some(n) => process::exit(n),
9-
None => {
10-
eprintln!("Killed by signal");
11-
process::exit(1);
12-
},
13-
}
14-
}
1+
use crate::{cargo_clippy_path, exit_if_err};
2+
use std::fs;
3+
use std::process::{self, Command};
154

165
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
176
let is_file = match fs::metadata(path) {

0 commit comments

Comments
 (0)