@@ -14,6 +14,7 @@ use crate::{
14
14
indenter:: indented,
15
15
list:: { BinaryList , OutputFormat , RustBuildMeta , Styles , TestListState } ,
16
16
reuse_build:: PathMapper ,
17
+ run_mode:: NextestRunMode ,
17
18
target_runner:: { PlatformRunner , TargetRunner } ,
18
19
test_command:: { LocalExecuteContext , TestCommand , TestCommandPhase } ,
19
20
test_filter:: { BinaryMismatchReason , FilterBinaryMatch , FilterBound , TestFilterBuilder } ,
@@ -42,7 +43,7 @@ use std::{
42
43
sync:: { Arc , OnceLock } ,
43
44
} ;
44
45
use tokio:: runtime:: Runtime ;
45
- use tracing:: debug;
46
+ use tracing:: { debug, trace } ;
46
47
47
48
/// A Rust test binary built by Cargo. This artifact hasn't been run yet so there's no information
48
49
/// about the tests within it.
@@ -201,6 +202,13 @@ pub struct SkipCounts {
201
202
/// The number of skipped tests.
202
203
pub skipped_tests : usize ,
203
204
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
+
204
212
/// The number of tests skipped due to not being in the default set.
205
213
pub skipped_tests_default_filter : usize ,
206
214
@@ -215,6 +223,7 @@ pub struct SkipCounts {
215
223
#[ derive( Clone , Debug ) ]
216
224
pub struct TestList < ' g > {
217
225
test_count : usize ,
226
+ mode : NextestRunMode ,
218
227
rust_build_meta : RustBuildMeta < TestListState > ,
219
228
rust_suites : BTreeMap < RustBinaryId , RustTestSuite < ' g > > ,
220
229
workspace_root : Utf8PathBuf ,
@@ -312,6 +321,7 @@ impl<'g> TestList<'g> {
312
321
313
322
Ok ( Self {
314
323
rust_suites,
324
+ mode : filter. mode ( ) ,
315
325
workspace_root,
316
326
env,
317
327
rust_build_meta,
@@ -370,6 +380,7 @@ impl<'g> TestList<'g> {
370
380
371
381
Ok ( Self {
372
382
rust_suites,
383
+ mode : filter. mode ( ) ,
373
384
workspace_root,
374
385
env,
375
386
rust_build_meta,
@@ -384,6 +395,11 @@ impl<'g> TestList<'g> {
384
395
self . test_count
385
396
}
386
397
398
+ /// Returns the mode nextest is running it.
399
+ pub fn mode ( & self ) -> NextestRunMode {
400
+ self . mode
401
+ }
402
+
387
403
/// Returns the Rust build-related metadata for this test list.
388
404
pub fn rust_build_meta ( & self ) -> & RustBuildMeta < TestListState > {
389
405
& self . rust_build_meta
@@ -392,10 +408,19 @@ impl<'g> TestList<'g> {
392
408
/// Returns the total number of skipped tests.
393
409
pub fn skip_counts ( & self ) -> & SkipCounts {
394
410
self . skip_counts . get_or_init ( || {
411
+ let mut skipped_tests_non_benchmark = 0 ;
395
412
let mut skipped_tests_default_filter = 0 ;
396
413
let skipped_tests = self
397
414
. iter_tests ( )
398
415
. 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
+ }
399
424
FilterMatch :: Mismatch {
400
425
reason : MismatchReason :: DefaultFilter ,
401
426
} => {
@@ -425,6 +450,7 @@ impl<'g> TestList<'g> {
425
450
426
451
SkipCounts {
427
452
skipped_tests,
453
+ skipped_tests_non_benchmark,
428
454
skipped_tests_default_filter,
429
455
skipped_binaries,
430
456
skipped_binaries_default_filter,
@@ -548,6 +574,7 @@ impl<'g> TestList<'g> {
548
574
pub ( crate ) fn empty ( ) -> Self {
549
575
Self {
550
576
test_count : 0 ,
577
+ mode : NextestRunMode :: Test ,
551
578
workspace_root : Utf8PathBuf :: new ( ) ,
552
579
rust_build_meta : RustBuildMeta :: empty ( ) ,
553
580
env : EnvironmentMap :: empty ( ) ,
@@ -605,18 +632,18 @@ impl<'g> TestList<'g> {
605
632
// based on one doesn't affect the other.
606
633
let mut non_ignored_filter = filter. build ( ) ;
607
634
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
+ ) ;
608
641
test_cases. insert (
609
642
test_name. into ( ) ,
610
643
RustTestCaseSummary {
611
644
kind : Some ( kind) ,
612
645
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,
620
647
} ,
621
648
) ;
622
649
}
@@ -627,18 +654,18 @@ impl<'g> TestList<'g> {
627
654
// * just ignored tests if --ignored is passed in
628
655
// * all tests, both ignored and non-ignored, if --ignored is not passed in
629
656
// 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
+ ) ;
630
663
test_cases. insert (
631
664
test_name. into ( ) ,
632
665
RustTestCaseSummary {
633
666
kind : Some ( kind) ,
634
667
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,
642
669
} ,
643
670
) ;
644
671
}
@@ -1127,6 +1154,15 @@ impl<'a> TestInstance<'a> {
1127
1154
if self . test_info . ignored {
1128
1155
cli. push ( "--ignored" ) ;
1129
1156
}
1157
+ match test_list. mode ( ) {
1158
+ NextestRunMode :: Benchmark => cli. push ( "--bench" ) ,
1159
+ NextestRunMode :: Test => {
1160
+ // We don't pass in additional arguments like "--test" here
1161
+ // because our ad-hoc custom harness protocol doesn't document
1162
+ // that as a requirement. This doesn't seem to be an issue in
1163
+ // practice, though.
1164
+ }
1165
+ }
1130
1166
cli. extend ( extra_args. iter ( ) . map ( String :: as_str) ) ;
1131
1167
1132
1168
let lctx = LocalExecuteContext {
@@ -1301,6 +1337,7 @@ mod tests {
1301
1337
let cx = ParseContext :: new ( & PACKAGE_GRAPH_FIXTURE ) ;
1302
1338
1303
1339
let test_filter = TestFilterBuilder :: new (
1340
+ NextestRunMode :: Test ,
1304
1341
RunIgnored :: Default ,
1305
1342
None ,
1306
1343
TestFilterPatterns :: default ( ) ,
@@ -1410,7 +1447,7 @@ mod tests {
1410
1447
filter_match: FilterMatch :: Mismatch { reason: MismatchReason :: Ignored } ,
1411
1448
} ,
1412
1449
"tests::baz::test_ignored" . to_owned( ) => RustTestCaseSummary {
1413
- kind: None ,
1450
+ kind: Some ( RustTestKind :: TEST ) ,
1414
1451
ignored: true ,
1415
1452
filter_match: FilterMatch :: Mismatch { reason: MismatchReason :: Ignored } ,
1416
1453
} ,
@@ -1539,6 +1576,7 @@ mod tests {
1539
1576
}
1540
1577
},
1541
1578
"tests::baz::test_ignored": {
1579
+ "kind": "test",
1542
1580
"ignored": true,
1543
1581
"filter-match": {
1544
1582
"status": "mismatch",
0 commit comments