@@ -12,18 +12,57 @@ fn dogfood() {
12
12
if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
13
13
return ;
14
14
}
15
- let root_dir = std:: env:: current_dir ( ) . unwrap ( ) ;
16
- for d in & [ "." , "clippy_lints" , "rustc_tools_util" , "clippy_dev" ] {
17
- std:: env:: set_current_dir ( root_dir. join ( d) ) . unwrap ( ) ;
18
- let output = std:: process:: Command :: new ( "cargo" )
19
- . arg ( "run" )
20
- . arg ( "--bin" )
21
- . arg ( "cargo-clippy" )
22
- . arg ( "--all-features" )
23
- . arg ( "--manifest-path" )
24
- . arg ( root_dir. join ( "Cargo.toml" ) )
25
- . args ( & [ "--" , "-W clippy::internal -W clippy::pedantic" ] )
26
- . env ( "CLIPPY_DOGFOOD" , "true" )
15
+ let root_dir = std:: path:: PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
16
+ let clippy_cmd = std:: path:: Path :: new ( & root_dir)
17
+ . join ( "target" )
18
+ . join ( env ! ( "PROFILE" ) )
19
+ . join ( "cargo-clippy" ) ;
20
+
21
+ let output = std:: process:: Command :: new ( clippy_cmd)
22
+ . current_dir ( root_dir)
23
+ . env ( "CLIPPY_DOGFOOD" , "1" )
24
+ . arg ( "clippy" )
25
+ . arg ( "--all-targets" )
26
+ . arg ( "--all-features" )
27
+ . arg ( "--" )
28
+ . args ( & [ "-D" , "clippy::all" ] )
29
+ . args ( & [ "-D" , "clippy::internal" ] )
30
+ . args ( & [ "-D" , "clippy::pedantic" ] )
31
+ . output ( )
32
+ . unwrap ( ) ;
33
+ println ! ( "status: {}" , output. status) ;
34
+ println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
35
+ println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
36
+
37
+ assert ! ( output. status. success( ) ) ;
38
+ }
39
+
40
+ #[ test]
41
+ fn dogfood_tests ( ) {
42
+ if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
43
+ return ;
44
+ }
45
+ let root_dir = std:: path:: PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
46
+ let clippy_cmd = std:: path:: Path :: new ( & root_dir)
47
+ . join ( "target" )
48
+ . join ( env ! ( "PROFILE" ) )
49
+ . join ( "cargo-clippy" ) ;
50
+
51
+ for d in & [
52
+ "clippy_workspace_tests" ,
53
+ "clippy_workspace_tests/src" ,
54
+ "clippy_workspace_tests/subcrate" ,
55
+ "clippy_workspace_tests/subcrate/src" ,
56
+ "clippy_dev" ,
57
+ "rustc_tools_util" ,
58
+ ] {
59
+ let output = std:: process:: Command :: new ( & clippy_cmd)
60
+ . current_dir ( root_dir. join ( d) )
61
+ . env ( "CLIPPY_DOGFOOD" , "1" )
62
+ . arg ( "clippy" )
63
+ . arg ( "--" )
64
+ . args ( & [ "-D" , "clippy::all" ] )
65
+ . args ( & [ "-D" , "clippy::pedantic" ] )
27
66
. output ( )
28
67
. unwrap ( ) ;
29
68
println ! ( "status: {}" , output. status) ;
0 commit comments