@@ -23,7 +23,7 @@ mod json;
2323
2424pub ( crate ) fn run_tests ( config : & Config , tests : Vec < CollectedTest > ) -> bool {
2525 let tests_len = tests. len ( ) ;
26- let filtered = filter_tests ( config, tests) ;
26+ let ( filtered, ignored ) = filter_tests ( config, tests) ;
2727 // Iterator yielding tests that haven't been started yet.
2828 let mut fresh_tests = ( 0 ..) . map ( TestId ) . zip ( & filtered) ;
2929
@@ -41,6 +41,11 @@ pub(crate) fn run_tests(config: &Config, tests: Vec<CollectedTest>) -> bool {
4141 let num_filtered_out = tests_len - filtered. len ( ) ;
4242 listener. suite_started ( filtered. len ( ) , num_filtered_out) ;
4343
44+ for ( id, test) in ( filtered. len ( ) ..) . map ( TestId ) . zip ( ignored) {
45+ let completion = TestCompletion { id, outcome : TestOutcome :: FilteredOut , stdout : None } ;
46+ listener. test_finished ( & test, & completion) ;
47+ }
48+
4449 // Channel used by test threads to report the test outcome when done.
4550 let ( completion_tx, completion_rx) = mpsc:: channel :: < TestCompletion > ( ) ;
4651
@@ -263,6 +268,7 @@ enum TestOutcome {
263268 Succeeded ,
264269 Failed { message : Option < & ' static str > } ,
265270 Ignored ,
271+ FilteredOut ,
266272}
267273
268274impl TestOutcome {
@@ -278,9 +284,10 @@ impl TestOutcome {
278284/// FIXME(#139660): Now that libtest has been removed, redesign the whole filtering system to
279285/// do a better job of understanding and filtering _paths_, instead of being tied to libtest's
280286/// substring/exact matching behaviour.
281- fn filter_tests ( opts : & Config , tests : Vec < CollectedTest > ) -> Vec < CollectedTest > {
282- let mut filtered = tests;
283-
287+ fn filter_tests (
288+ opts : & Config ,
289+ tests : Vec < CollectedTest > ,
290+ ) -> ( Vec < CollectedTest > , Vec < CollectedTest > ) {
284291 let matches_filter = |test : & CollectedTest , filter_str : & str | {
285292 if opts. filter_exact {
286293 // When `--exact` is used we must use `filterable_path` to get
@@ -293,17 +300,23 @@ fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest>
293300 }
294301 } ;
295302
296- // Remove tests that don't match the test filter
297- if !opts. filters . is_empty ( ) {
298- filtered. retain ( |test| opts. filters . iter ( ) . any ( |filter| matches_filter ( test, filter) ) ) ;
299- }
303+ let should_run = |test : & CollectedTest | {
304+ // Remove tests that don't match the test filter
305+ if !opts. filters . is_empty ( )
306+ && !opts. filters . iter ( ) . any ( |filter| matches_filter ( test, filter) )
307+ {
308+ return false ;
309+ }
300310
301- // Skip tests that match any of the skip filters
302- if !opts. skip . is_empty ( ) {
303- filtered. retain ( |test| !opts. skip . iter ( ) . any ( |sf| matches_filter ( test, sf) ) ) ;
304- }
311+ // Skip tests that match any of the skip filters
312+ if opts. skip . iter ( ) . any ( |sf| matches_filter ( test, sf) ) {
313+ return false ;
314+ }
315+
316+ true
317+ } ;
305318
306- filtered
319+ tests . into_iter ( ) . partition ( should_run )
307320}
308321
309322/// Determines the number of tests to run concurrently.
0 commit comments