7
7
#![ warn( rust_2018_idioms, unused_lifetimes) ]
8
8
9
9
use itertools:: Itertools ;
10
+ use std:: fs:: File ;
11
+ use std:: io:: { self , IsTerminal } ;
10
12
use std:: path:: PathBuf ;
11
13
use std:: process:: Command ;
14
+ use std:: time:: SystemTime ;
12
15
use test_utils:: IS_RUSTC_TEST_SUITE ;
16
+ use ui_test:: Args ;
13
17
14
18
mod test_utils;
15
19
16
- #[ test]
17
- fn dogfood_clippy ( ) {
20
+ fn main ( ) {
18
21
if IS_RUSTC_TEST_SUITE {
19
22
return ;
20
23
}
21
24
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 ( ) {
22
41
let mut failed_packages = Vec :: new ( ) ;
23
42
24
- // "" is the root package
25
43
for package in [
26
- "" ,
44
+ "./ " ,
27
45
"clippy_dev" ,
28
46
"clippy_lints" ,
29
47
"clippy_utils" ,
30
48
"clippy_config" ,
31
49
"lintcheck" ,
32
50
"rustc_tools_util" ,
33
51
] {
52
+ println ! ( "linting {package}" ) ;
34
53
if !run_clippy_for_package ( package, & [ "-D" , "clippy::all" , "-D" , "clippy::pedantic" ] ) {
35
54
failed_packages. push ( if package. is_empty ( ) { "root" } else { package } ) ;
36
55
}
@@ -43,12 +62,8 @@ fn dogfood_clippy() {
43
62
) ;
44
63
}
45
64
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" ) ) ;
52
67
53
68
// Setup for validation
54
69
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 {
101
116
. arg ( "--all-targets" )
102
117
. arg ( "--all-features" ) ;
103
118
119
+ if !io:: stdout ( ) . is_terminal ( ) {
120
+ command. arg ( "-q" ) ;
121
+ }
122
+
104
123
if let Ok ( dogfood_args) = std:: env:: var ( "__CLIPPY_DOGFOOD_ARGS" ) {
105
124
for arg in dogfood_args. split_whitespace ( ) {
106
125
command. arg ( arg) ;
@@ -119,11 +138,5 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
119
138
command. args ( [ "-A" , "unknown_lints" ] ) ;
120
139
}
121
140
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 ( )
129
142
}
0 commit comments