Skip to content

Commit acc41f4

Browse files
committed
Auto merge of rust-lang#13100 - Alexendoo:dogfood-progress, r=xFrednet
Show progress while running dogfood test Outputs the regular cargo progress in colour when running the dogfood test, helpful to see because it can take a long time to run changelog: none
2 parents f74037e + 0b0c39c commit acc41f4

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ uibless = "test --test compile-test -- -- --bless"
44
bless = "test -- -- --bless"
55
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
66
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
7-
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored"
7+
collect-metadata = "test --test dogfood --features internal -- collect_metadata"
88

99
[build]
1010
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ ui_test = "0.24"
3434
regex = "1.5.5"
3535
toml = "0.7.3"
3636
walkdir = "2.3"
37-
# This is used by the `collect-metadata` alias.
3837
filetime = "0.2.9"
3938
itertools = "0.12"
4039

@@ -63,3 +62,7 @@ rustc_private = true
6362
[[test]]
6463
name = "compile-test"
6564
harness = false
65+
66+
[[test]]
67+
name = "dogfood"
68+
harness = false

tests/dogfood.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,49 @@
77
#![warn(rust_2018_idioms, unused_lifetimes)]
88

99
use itertools::Itertools;
10+
use std::fs::File;
11+
use std::io::{self, IsTerminal};
1012
use std::path::PathBuf;
1113
use std::process::Command;
14+
use std::time::SystemTime;
1215
use test_utils::IS_RUSTC_TEST_SUITE;
16+
use ui_test::Args;
1317

1418
mod test_utils;
1519

16-
#[test]
17-
fn dogfood_clippy() {
20+
fn main() {
1821
if IS_RUSTC_TEST_SUITE {
1922
return;
2023
}
2124

25+
let args = Args::test().unwrap();
26+
27+
if args.list {
28+
if !args.ignored {
29+
println!("dogfood: test");
30+
}
31+
} else if !args.skip.iter().any(|arg| arg == "dogfood") {
32+
if args.filters.iter().any(|arg| arg == "collect_metadata") {
33+
collect_metadata();
34+
} else {
35+
dogfood();
36+
}
37+
}
38+
}
39+
40+
fn dogfood() {
2241
let mut failed_packages = Vec::new();
2342

24-
// "" is the root package
2543
for package in [
26-
"",
44+
"./",
2745
"clippy_dev",
2846
"clippy_lints",
2947
"clippy_utils",
3048
"clippy_config",
3149
"lintcheck",
3250
"rustc_tools_util",
3351
] {
52+
println!("linting {package}");
3453
if !run_clippy_for_package(package, &["-D", "clippy::all", "-D", "clippy::pedantic"]) {
3554
failed_packages.push(if package.is_empty() { "root" } else { package });
3655
}
@@ -43,12 +62,8 @@ fn dogfood_clippy() {
4362
);
4463
}
4564

46-
#[test]
47-
#[ignore]
48-
#[cfg(feature = "internal")]
49-
fn run_metadata_collection_lint() {
50-
use std::fs::File;
51-
use std::time::SystemTime;
65+
fn collect_metadata() {
66+
assert!(cfg!(feature = "internal"));
5267

5368
// Setup for validation
5469
let metadata_output_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("util/gh-pages/lints.json");
@@ -101,6 +116,10 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
101116
.arg("--all-targets")
102117
.arg("--all-features");
103118

119+
if !io::stdout().is_terminal() {
120+
command.arg("-q");
121+
}
122+
104123
if let Ok(dogfood_args) = std::env::var("__CLIPPY_DOGFOOD_ARGS") {
105124
for arg in dogfood_args.split_whitespace() {
106125
command.arg(arg);
@@ -119,11 +138,5 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
119138
command.args(["-A", "unknown_lints"]);
120139
}
121140

122-
let output = command.output().unwrap();
123-
124-
println!("status: {}", output.status);
125-
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
126-
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
127-
128-
output.status.success()
141+
command.status().unwrap().success()
129142
}

0 commit comments

Comments
 (0)