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