77#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
88#![ warn( rust_2018_idioms, unused_lifetimes) ]
99
10+ use itertools:: Itertools ;
1011use std:: path:: PathBuf ;
1112use std:: process:: Command ;
1213use test_utils:: IS_RUSTC_TEST_SUITE ;
@@ -19,17 +20,27 @@ fn dogfood_clippy() {
1920 return ;
2021 }
2122
23+ let mut failed_packages = Vec :: new ( ) ;
24+
2225 // "" is the root package
23- for package in & [
26+ for package in [
2427 "" ,
2528 "clippy_dev" ,
2629 "clippy_lints" ,
2730 "clippy_utils" ,
2831 "lintcheck" ,
2932 "rustc_tools_util" ,
3033 ] {
31- run_clippy_for_package ( package, & [ "-D" , "clippy::all" , "-D" , "clippy::pedantic" ] ) ;
34+ if !run_clippy_for_package ( package, & [ "-D" , "clippy::all" , "-D" , "clippy::pedantic" ] ) {
35+ failed_packages. push ( if package. is_empty ( ) { "root" } else { package } ) ;
36+ }
3237 }
38+
39+ assert ! (
40+ !failed_packages. is_empty( ) ,
41+ "Dogfood failed for packages `{}`" ,
42+ failed_packages. iter( ) . format( ", " ) ,
43+ )
3344}
3445
3546#[ test]
@@ -71,7 +82,7 @@ fn run_metadata_collection_lint() {
7182 run_clippy_for_package ( "clippy_lints" , & [ "-A" , "unfulfilled_lint_expectations" ] ) ;
7283}
7384
74- fn run_clippy_for_package ( project : & str , args : & [ & str ] ) {
85+ fn run_clippy_for_package ( project : & str , args : & [ & str ] ) -> bool {
7586 let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
7687
7788 let mut command = Command :: new ( & * test_utils:: CARGO_CLIPPY_PATH ) ;
@@ -107,5 +118,5 @@ fn run_clippy_for_package(project: &str, args: &[&str]) {
107118 println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
108119 println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
109120
110- assert ! ( output. status. success( ) ) ;
121+ output. status . success ( )
111122}
0 commit comments