77#![ warn( rust_2018_idioms, unused_lifetimes) ]
88
99use itertools:: Itertools ;
10+ use std:: fs:: File ;
11+ use std:: io:: { self , IsTerminal } ;
1012use std:: path:: PathBuf ;
1113use std:: process:: Command ;
14+ use std:: time:: SystemTime ;
1215use test_utils:: IS_RUSTC_TEST_SUITE ;
16+ use ui_test:: Args ;
1317
1418mod 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