Skip to content

Commit

Permalink
Show progress while running dogfood test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexendoo committed Jul 15, 2024
1 parent 22eeb11 commit 292c3b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ uibless = "test --test compile-test -- -- --bless"
bless = "test -- -- --bless"
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored"
collect-metadata = "test --test dogfood --features internal -- collect-metadata"

[build]
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ ui_test = "0.24"
regex = "1.5.5"
toml = "0.7.3"
walkdir = "2.3"
# This is used by the `collect-metadata` alias.
filetime = "0.2.9"
itertools = "0.12"

Expand Down Expand Up @@ -63,3 +62,7 @@ rustc_private = true
[[test]]
name = "compile-test"
harness = false

[[test]]
name = "dogfood"
harness = false
33 changes: 16 additions & 17 deletions tests/dogfood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@
#![warn(rust_2018_idioms, unused_lifetimes)]

use itertools::Itertools;
use std::fs::File;
use std::path::PathBuf;
use std::process::Command;
use std::time::SystemTime;
use test_utils::IS_RUSTC_TEST_SUITE;

mod test_utils;

#[test]
fn main() {
if std::env::args().any(|arg| arg == "collect-metadata") {
collect_metadata();
} else {
dogfood_clippy();
}
}

fn dogfood_clippy() {
if IS_RUSTC_TEST_SUITE {
return;
}

let mut failed_packages = Vec::new();

// "" is the root package
for package in [
"",
"./",
"clippy_dev",
"clippy_lints",
"clippy_utils",
Expand All @@ -43,12 +51,8 @@ fn dogfood_clippy() {
);
}

#[test]
#[ignore]
#[cfg(feature = "internal")]
fn run_metadata_collection_lint() {
use std::fs::File;
use std::time::SystemTime;
fn collect_metadata() {
assert!(cfg!(feature = "internal"));

// Setup for validation
let metadata_output_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("util/gh-pages/lints.json");
Expand Down Expand Up @@ -90,6 +94,8 @@ fn run_metadata_collection_lint() {

#[must_use]
fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
println!("linting {project}");

let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

let mut command = Command::new(&*test_utils::CARGO_CLIPPY_PATH);
Expand Down Expand Up @@ -118,12 +124,5 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
// that contains e.g. `allow(clippy::invalid_paths)`
command.args(["-A", "unknown_lints"]);
}

let output = command.output().unwrap();

println!("status: {}", output.status);
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));

output.status.success()
command.status().unwrap().success()
}

0 comments on commit 292c3b4

Please sign in to comment.