Skip to content

Commit 95a3a72

Browse files
committed
Auto merge of #103795 - thomcc:untest, r=Mark-Simulacrum
Include both benchmarks and tests in the numbers given to `TeFiltered{,Out}` Fixes #103794 `#[bench]` is broken on nightly without this, sadly. It apparently has no test coverage. In addition to manually testing, I've added a run-make smokecheck for this (which would have caught the issue), but it would be nice to have a better way to test, err, libtest. For now we should get this in ASAP IMO
2 parents 2afca78 + bf88755 commit 95a3a72

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Diff for: library/test/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ impl FilteredTests {
246246
}));
247247
self.add_test(desc, testfn);
248248
}
249+
fn total_len(&self) -> usize {
250+
self.tests.len() + self.benchs.len()
251+
}
249252
}
250253

251254
pub fn run_tests<F>(
@@ -303,13 +306,13 @@ where
303306
};
304307
}
305308

306-
let filtered_out = tests_len - filtered.tests.len();
309+
let filtered_out = tests_len - filtered.total_len();
307310
let event = TestEvent::TeFilteredOut(filtered_out);
308311
notify_about_test_event(event)?;
309312

310313
let shuffle_seed = get_shuffle_seed(opts);
311314

312-
let event = TestEvent::TeFiltered(filtered.tests.len(), shuffle_seed);
315+
let event = TestEvent::TeFiltered(filtered.total_len(), shuffle_seed);
313316
notify_about_test_event(event)?;
314317

315318
let concurrency = opts.test_threads.unwrap_or_else(get_concurrency);

Diff for: src/test/run-make/test-benches/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include ../../run-make-fulldeps/tools.mk
2+
3+
# ignore-cross-compile
4+
5+
all:
6+
# Smoke-test that `#[bench]` isn't entirely broken.
7+
$(RUSTC) --test smokebench.rs -O
8+
$(call RUN,smokebench --bench)
9+
$(call RUN,smokebench --bench noiter)
10+
$(call RUN,smokebench --bench yesiter)
11+
$(call RUN,smokebench)

Diff for: src/test/run-make/test-benches/smokebench.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(test)]
2+
extern crate test;
3+
4+
#[bench]
5+
fn smoke_yesiter(b: &mut test::Bencher) {
6+
let mut i = 0usize;
7+
b.iter(|| {
8+
i = i.wrapping_add(1);
9+
i
10+
})
11+
}
12+
13+
#[bench]
14+
fn smoke_noiter(_: &mut test::Bencher) {}

0 commit comments

Comments
 (0)