@@ -139,8 +139,10 @@ pub fn run_tests(mut config: Config) -> Result<()> {
139
139
140
140
/// The filter used by `run_tests` to only run on `.rs` files that are
141
141
/// specified by [`Config::filter_files`] and [`Config::skip_files`].
142
- pub fn default_file_filter ( path : & Path , config : & Config ) -> bool {
143
- path. extension ( ) . is_some_and ( |ext| ext == "rs" ) && default_any_file_filter ( path, config)
142
+ /// Returns `None` if there is no extension or the extension is not `.rs`.
143
+ pub fn default_file_filter ( path : & Path , config : & Config ) -> Option < bool > {
144
+ path. extension ( ) . filter ( |& ext| ext == "rs" ) ?;
145
+ Some ( default_any_file_filter ( path, config) )
144
146
}
145
147
146
148
/// Run on all files that are specified by [`Config::filter_files`] and
@@ -203,8 +205,6 @@ pub enum TestOk {
203
205
Ok ,
204
206
/// The test was ignored due to a rule (`//@only-*` or `//@ignore-*`)
205
207
Ignored ,
206
- /// The test was filtered with the `file_filter` argument.
207
- Filtered ,
208
208
}
209
209
210
210
/// The possible results a single test can have.
@@ -233,9 +233,12 @@ struct TestRun {
233
233
/// All `configs` are being run in parallel.
234
234
/// If multiple configs are provided, the [`Config::threads`] value of the first one is used;
235
235
/// the thread count of all other configs is ignored.
236
+ /// The file filter is supposed to return `None` if it was filtered because of file extensions
237
+ /// and `Some(false)` if the file was rejected out of other reasons like the file path not matching
238
+ /// a user defined filter.
236
239
pub fn run_tests_generic (
237
240
mut configs : Vec < Config > ,
238
- file_filter : impl Fn ( & Path , & Config ) -> bool + Sync ,
241
+ file_filter : impl Fn ( & Path , & Config ) -> Option < bool > + Sync ,
239
242
per_file_config : impl Fn ( & mut Config , & Path , & [ u8 ] ) + Sync ,
240
243
status_emitter : impl StatusEmitter + Send ,
241
244
) -> Result < ( ) > {
@@ -275,6 +278,7 @@ pub fn run_tests_generic(
275
278
} ,
276
279
} ;
277
280
281
+ let mut filtered = 0 ;
278
282
run_and_collect (
279
283
num_threads,
280
284
|submit| {
@@ -297,10 +301,14 @@ pub fn run_tests_generic(
297
301
for entry in entries {
298
302
todo. push_back ( ( entry, config) ) ;
299
303
}
300
- } else if file_filter ( & path, config) {
301
- let status = status_emitter. register_test ( path) ;
302
- // Forward .rs files to the test workers.
303
- submit. send ( ( status, config) ) . unwrap ( ) ;
304
+ } else if let Some ( matched) = file_filter ( & path, config) {
305
+ if matched {
306
+ let status = status_emitter. register_test ( path) ;
307
+ // Forward .rs files to the test workers.
308
+ submit. send ( ( status, config) ) . unwrap ( ) ;
309
+ } else {
310
+ filtered += 1 ;
311
+ }
304
312
}
305
313
}
306
314
} ,
@@ -357,13 +365,11 @@ pub fn run_tests_generic(
357
365
let mut failures = vec ! [ ] ;
358
366
let mut succeeded = 0 ;
359
367
let mut ignored = 0 ;
360
- let mut filtered = 0 ;
361
368
362
369
for run in results {
363
370
match run. result {
364
371
Ok ( TestOk :: Ok ) => succeeded += 1 ,
365
372
Ok ( TestOk :: Ignored ) => ignored += 1 ,
366
- Ok ( TestOk :: Filtered ) => filtered += 1 ,
367
373
Err ( errored) => failures. push ( ( run. status , errored) ) ,
368
374
}
369
375
}
0 commit comments