@@ -22,14 +22,12 @@ fn dogfood_clippy() {
2222 return ;
2323 }
2424 let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
25- let enable_metadata_collection = std:: env:: var ( "ENABLE_METADATA_COLLECTION" ) . unwrap_or_else ( |_| "0" . to_string ( ) ) ;
2625
2726 let mut command = Command :: new ( & * CLIPPY_PATH ) ;
2827 command
2928 . current_dir ( root_dir)
3029 . env ( "CLIPPY_DOGFOOD" , "1" )
3130 . env ( "CARGO_INCREMENTAL" , "0" )
32- . env ( "ENABLE_METADATA_COLLECTION" , & enable_metadata_collection)
3331 . arg ( "clippy" )
3432 . arg ( "--all-targets" )
3533 . arg ( "--all-features" )
@@ -157,10 +155,9 @@ fn dogfood_subprojects() {
157155 if cargo:: is_rustc_test_suite ( ) {
158156 return ;
159157 }
160- let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
161158
162159 // NOTE: `path_dep` crate is omitted on purpose here
163- for d in & [
160+ for project in & [
164161 "clippy_workspace_tests" ,
165162 "clippy_workspace_tests/src" ,
166163 "clippy_workspace_tests/subcrate" ,
@@ -170,34 +167,49 @@ fn dogfood_subprojects() {
170167 "clippy_utils" ,
171168 "rustc_tools_util" ,
172169 ] {
173- let mut command = Command :: new ( & * CLIPPY_PATH ) ;
174- command
175- . current_dir ( root_dir. join ( d) )
176- . env ( "CLIPPY_DOGFOOD" , "1" )
177- . env ( "CARGO_INCREMENTAL" , "0" )
178- . arg ( "clippy" )
179- . arg ( "--all-targets" )
180- . arg ( "--all-features" )
181- . arg ( "--" )
182- . args ( & [ "-D" , "clippy::all" ] )
183- . args ( & [ "-D" , "clippy::pedantic" ] )
184- . arg ( "-Cdebuginfo=0" ) ; // disable debuginfo to generate less data in the target dir
170+ run_clippy_for_project ( project) ;
171+ }
172+
173+ // NOTE: Since tests run in parallel we can't run cargo commands on the same workspace at the
174+ // same time, so we test this immediately after the dogfood for workspaces.
175+ test_no_deps_ignores_path_deps_in_workspaces ( ) ;
176+ }
185177
186- // internal lints only exist if we build with the internal-lints feature
187- if cfg ! ( feature = "internal-lints" ) {
188- command. args ( & [ "-D" , "clippy::internal" ] ) ;
189- }
178+ #[ test]
179+ #[ ignore]
180+ #[ cfg( feature = "metadata-collector-lint" ) ]
181+ fn run_metadata_collection_lint ( ) {
182+ std:: env:: set_var ( "ENABLE_METADATA_COLLECTION" , "1" ) ;
183+ run_clippy_for_project ( "clippy_lints" ) ;
184+ }
190185
191- let output = command. output ( ) . unwrap ( ) ;
186+ fn run_clippy_for_project ( project : & str ) {
187+ let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
192188
193- println ! ( "status: {}" , output. status) ;
194- println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
195- println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
189+ let mut command = Command :: new ( & * CLIPPY_PATH ) ;
196190
197- assert ! ( output. status. success( ) ) ;
191+ command
192+ . current_dir ( root_dir. join ( project) )
193+ . env ( "CLIPPY_DOGFOOD" , "1" )
194+ . env ( "CARGO_INCREMENTAL" , "0" )
195+ . arg ( "clippy" )
196+ . arg ( "--all-targets" )
197+ . arg ( "--all-features" )
198+ . arg ( "--" )
199+ . args ( & [ "-D" , "clippy::all" ] )
200+ . args ( & [ "-D" , "clippy::pedantic" ] )
201+ . arg ( "-Cdebuginfo=0" ) ; // disable debuginfo to generate less data in the target dir
202+
203+ // internal lints only exist if we build with the internal-lints feature
204+ if cfg ! ( feature = "internal-lints" ) {
205+ command. args ( & [ "-D" , "clippy::internal" ] ) ;
198206 }
199207
200- // NOTE: Since tests run in parallel we can't run cargo commands on the same workspace at the
201- // same time, so we test this immediately after the dogfood for workspaces.
202- test_no_deps_ignores_path_deps_in_workspaces ( ) ;
208+ let output = command. output ( ) . unwrap ( ) ;
209+
210+ println ! ( "status: {}" , output. status) ;
211+ println ! ( "stdout: {}" , String :: from_utf8_lossy( & output. stdout) ) ;
212+ println ! ( "stderr: {}" , String :: from_utf8_lossy( & output. stderr) ) ;
213+
214+ assert ! ( output. status. success( ) ) ;
203215}
0 commit comments