7
7
#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
8
8
#![ warn( rust_2018_idioms, unused_lifetimes) ]
9
9
10
+ use itertools:: Itertools ;
10
11
use std:: path:: PathBuf ;
11
12
use std:: process:: Command ;
12
13
use test_utils:: IS_RUSTC_TEST_SUITE ;
@@ -19,17 +20,27 @@ fn dogfood_clippy() {
19
20
return ;
20
21
}
21
22
23
+ let mut failed_packages = Vec :: new ( ) ;
24
+
22
25
// "" is the root package
23
- for package in & [
26
+ for package in [
24
27
"" ,
25
28
"clippy_dev" ,
26
29
"clippy_lints" ,
27
30
"clippy_utils" ,
28
31
"lintcheck" ,
29
32
"rustc_tools_util" ,
30
33
] {
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
+ }
32
37
}
38
+
39
+ assert ! (
40
+ !failed_packages. is_empty( ) ,
41
+ "Dogfood failed for packages `{}`" ,
42
+ failed_packages. iter( ) . format( ", " ) ,
43
+ )
33
44
}
34
45
35
46
#[ test]
@@ -71,7 +82,7 @@ fn run_metadata_collection_lint() {
71
82
run_clippy_for_package ( "clippy_lints" , & [ "-A" , "unfulfilled_lint_expectations" ] ) ;
72
83
}
73
84
74
- fn run_clippy_for_package ( project : & str , args : & [ & str ] ) {
85
+ fn run_clippy_for_package ( project : & str , args : & [ & str ] ) -> bool {
75
86
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
76
87
77
88
let mut command = Command :: new ( & * test_utils:: CARGO_CLIPPY_PATH ) ;
@@ -107,5 +118,5 @@ fn run_clippy_for_package(project: &str, args: &[&str]) {
107
118
println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
108
119
println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
109
120
110
- assert ! ( output. status. success( ) ) ;
121
+ output. status . success ( )
111
122
}
0 commit comments