9
9
10
10
use std:: path:: PathBuf ;
11
11
use std:: process:: Command ;
12
- use test_utils:: { CARGO_CLIPPY_PATH , IS_RUSTC_TEST_SUITE } ;
12
+ use test_utils:: IS_RUSTC_TEST_SUITE ;
13
13
14
14
mod test_utils;
15
15
16
16
#[ test]
17
17
fn dogfood_clippy ( ) {
18
- // run clippy on itself and fail the test if lint warnings are reported
19
- if IS_RUSTC_TEST_SUITE {
20
- return ;
21
- }
22
- let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
23
-
24
- let mut command = Command :: new ( & * CARGO_CLIPPY_PATH ) ;
25
- command
26
- . current_dir ( root_dir)
27
- . env ( "CARGO_INCREMENTAL" , "0" )
28
- . arg ( "clippy" )
29
- . arg ( "--all-targets" )
30
- . arg ( "--all-features" )
31
- . arg ( "--" )
32
- . args ( & [ "-D" , "clippy::all" ] )
33
- . args ( & [ "-D" , "clippy::pedantic" ] )
34
- . arg ( "-Cdebuginfo=0" ) ; // disable debuginfo to generate less data in the target dir
35
-
36
- // internal lints only exist if we build with the internal feature
37
- if cfg ! ( feature = "internal" ) {
38
- command. args ( & [ "-D" , "clippy::internal" ] ) ;
39
- }
40
-
41
- let output = command. output ( ) . unwrap ( ) ;
42
-
43
- println ! ( "status: {}" , output. status) ;
44
- println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
45
- println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
46
-
47
- assert ! ( output. status. success( ) ) ;
48
- }
49
-
50
- #[ test]
51
- fn dogfood_subprojects ( ) {
52
- // run clippy on remaining subprojects and fail the test if lint warnings are reported
53
18
if IS_RUSTC_TEST_SUITE {
54
19
return ;
55
20
}
56
21
57
- // NOTE: `path_dep` crate is omitted on purpose here
58
- for project in & [ "clippy_dev" , "clippy_lints" , "clippy_utils" , "rustc_tools_util" ] {
59
- run_clippy_for_project ( project ) ;
22
+ // "" is the root package
23
+ for package in & [ "" , "clippy_dev" , "clippy_lints" , "clippy_utils" , "rustc_tools_util" ] {
24
+ run_clippy_for_package ( package ) ;
60
25
}
61
26
}
62
27
@@ -73,7 +38,7 @@ fn run_metadata_collection_lint() {
73
38
74
39
// Run collection as is
75
40
std:: env:: set_var ( "ENABLE_METADATA_COLLECTION" , "1" ) ;
76
- run_clippy_for_project ( "clippy_lints" ) ;
41
+ run_clippy_for_package ( "clippy_lints" ) ;
77
42
78
43
// Check if cargo caching got in the way
79
44
if let Ok ( file) = File :: open ( metadata_output_path) {
@@ -96,10 +61,10 @@ fn run_metadata_collection_lint() {
96
61
. unwrap ( ) ;
97
62
98
63
// Running the collection again
99
- run_clippy_for_project ( "clippy_lints" ) ;
64
+ run_clippy_for_package ( "clippy_lints" ) ;
100
65
}
101
66
102
- fn run_clippy_for_project ( project : & str ) {
67
+ fn run_clippy_for_package ( project : & str ) {
103
68
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
104
69
105
70
let mut command = Command :: new ( & * test_utils:: CARGO_CLIPPY_PATH ) ;
0 commit comments