@@ -14,6 +14,7 @@ use crate::{
1414 indenter:: indented,
1515 list:: { BinaryList , OutputFormat , RustBuildMeta , Styles , TestListState } ,
1616 reuse_build:: PathMapper ,
17+ run_mode:: NextestRunMode ,
1718 target_runner:: { PlatformRunner , TargetRunner } ,
1819 test_command:: { LocalExecuteContext , TestCommand , TestCommandPhase } ,
1920 test_filter:: { BinaryMismatchReason , FilterBinaryMatch , FilterBound , TestFilterBuilder } ,
@@ -42,7 +43,7 @@ use std::{
4243 sync:: { Arc , OnceLock } ,
4344} ;
4445use tokio:: runtime:: Runtime ;
45- use tracing:: debug;
46+ use tracing:: { debug, trace } ;
4647
4748/// A Rust test binary built by Cargo. This artifact hasn't been run yet so there's no information
4849/// about the tests within it.
@@ -201,6 +202,13 @@ pub struct SkipCounts {
201202 /// The number of skipped tests.
202203 pub skipped_tests : usize ,
203204
205+ /// The number of tests skipped due to not being benchmarks.
206+ ///
207+ /// This is the highest-priority reason for skipping tests.
208+ ///
209+ /// This is non-zero only when running in benchmark mode.
210+ pub skipped_tests_non_benchmark : usize ,
211+
204212 /// The number of tests skipped due to not being in the default set.
205213 pub skipped_tests_default_filter : usize ,
206214
@@ -215,6 +223,7 @@ pub struct SkipCounts {
215223#[ derive( Clone , Debug ) ]
216224pub struct TestList < ' g > {
217225 test_count : usize ,
226+ mode : NextestRunMode ,
218227 rust_build_meta : RustBuildMeta < TestListState > ,
219228 rust_suites : BTreeMap < RustBinaryId , RustTestSuite < ' g > > ,
220229 workspace_root : Utf8PathBuf ,
@@ -312,6 +321,7 @@ impl<'g> TestList<'g> {
312321
313322 Ok ( Self {
314323 rust_suites,
324+ mode : filter. mode ( ) ,
315325 workspace_root,
316326 env,
317327 rust_build_meta,
@@ -370,6 +380,7 @@ impl<'g> TestList<'g> {
370380
371381 Ok ( Self {
372382 rust_suites,
383+ mode : filter. mode ( ) ,
373384 workspace_root,
374385 env,
375386 rust_build_meta,
@@ -384,6 +395,11 @@ impl<'g> TestList<'g> {
384395 self . test_count
385396 }
386397
398+ /// Returns the mode nextest is running it.
399+ pub fn mode ( & self ) -> NextestRunMode {
400+ self . mode
401+ }
402+
387403 /// Returns the Rust build-related metadata for this test list.
388404 pub fn rust_build_meta ( & self ) -> & RustBuildMeta < TestListState > {
389405 & self . rust_build_meta
@@ -392,10 +408,19 @@ impl<'g> TestList<'g> {
392408 /// Returns the total number of skipped tests.
393409 pub fn skip_counts ( & self ) -> & SkipCounts {
394410 self . skip_counts . get_or_init ( || {
411+ let mut skipped_tests_non_benchmark = 0 ;
395412 let mut skipped_tests_default_filter = 0 ;
396413 let skipped_tests = self
397414 . iter_tests ( )
398415 . filter ( |instance| match instance. test_info . filter_match {
416+ FilterMatch :: Mismatch {
417+ reason : MismatchReason :: NotBenchmark ,
418+ } => {
419+ // If we're running in benchmark mode, we track but
420+ // don't show skip counts for non-benchmark tests.
421+ skipped_tests_non_benchmark += 1 ;
422+ true
423+ }
399424 FilterMatch :: Mismatch {
400425 reason : MismatchReason :: DefaultFilter ,
401426 } => {
@@ -425,6 +450,7 @@ impl<'g> TestList<'g> {
425450
426451 SkipCounts {
427452 skipped_tests,
453+ skipped_tests_non_benchmark,
428454 skipped_tests_default_filter,
429455 skipped_binaries,
430456 skipped_binaries_default_filter,
@@ -548,6 +574,7 @@ impl<'g> TestList<'g> {
548574 pub ( crate ) fn empty ( ) -> Self {
549575 Self {
550576 test_count : 0 ,
577+ mode : NextestRunMode :: Test ,
551578 workspace_root : Utf8PathBuf :: new ( ) ,
552579 rust_build_meta : RustBuildMeta :: empty ( ) ,
553580 env : EnvironmentMap :: empty ( ) ,
@@ -605,18 +632,18 @@ impl<'g> TestList<'g> {
605632 // based on one doesn't affect the other.
606633 let mut non_ignored_filter = filter. build ( ) ;
607634 for ( test_name, kind) in Self :: parse ( & test_binary. binary_id , non_ignored. as_ref ( ) ) ? {
635+ let filter_match =
636+ non_ignored_filter. filter_match ( & test_binary, test_name, & kind, ecx, bound, false ) ;
637+ trace ! (
638+ "test binary {}: test {} ({kind:?}) matches non-ignored filter: {filter_match:?}" ,
639+ test_binary. binary_id, test_name,
640+ ) ;
608641 test_cases. insert (
609642 test_name. into ( ) ,
610643 RustTestCaseSummary {
611644 kind,
612645 ignored : false ,
613- filter_match : non_ignored_filter. filter_match (
614- & test_binary,
615- test_name,
616- ecx,
617- bound,
618- false ,
619- ) ,
646+ filter_match,
620647 } ,
621648 ) ;
622649 }
@@ -627,18 +654,18 @@ impl<'g> TestList<'g> {
627654 // * just ignored tests if --ignored is passed in
628655 // * all tests, both ignored and non-ignored, if --ignored is not passed in
629656 // Adding ignored tests after non-ignored ones makes everything resolve correctly.
657+ let filter_match =
658+ ignored_filter. filter_match ( & test_binary, test_name, & kind, ecx, bound, true ) ;
659+ trace ! (
660+ "test binary {}: test {} ({kind:?}) matches ignored filter: {filter_match:?}" ,
661+ test_binary. binary_id, test_name,
662+ ) ;
630663 test_cases. insert (
631664 test_name. into ( ) ,
632665 RustTestCaseSummary {
633666 kind,
634667 ignored : true ,
635- filter_match : ignored_filter. filter_match (
636- & test_binary,
637- test_name,
638- ecx,
639- bound,
640- true ,
641- ) ,
668+ filter_match,
642669 } ,
643670 ) ;
644671 }
@@ -1129,6 +1156,15 @@ impl<'a> TestInstance<'a> {
11291156 if self . test_info . ignored {
11301157 cli. push ( "--ignored" ) ;
11311158 }
1159+ match test_list. mode ( ) {
1160+ NextestRunMode :: Benchmark => cli. push ( "--bench" ) ,
1161+ NextestRunMode :: Test => {
1162+ // We don't pass in additional arguments like "--test" here
1163+ // because our ad-hoc custom harness protocol doesn't document
1164+ // that as a requirement. This doesn't seem to be an issue in
1165+ // practice, though.
1166+ }
1167+ }
11321168 cli. extend ( extra_args. iter ( ) . map ( String :: as_str) ) ;
11331169
11341170 let lctx = LocalExecuteContext {
@@ -1303,6 +1339,7 @@ mod tests {
13031339 let cx = ParseContext :: new ( & PACKAGE_GRAPH_FIXTURE ) ;
13041340
13051341 let test_filter = TestFilterBuilder :: new (
1342+ NextestRunMode :: Test ,
13061343 RunIgnored :: Default ,
13071344 None ,
13081345 TestFilterPatterns :: default ( ) ,
0 commit comments