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
This commit is contained in:
bors 2022-10-31 18:50:06 +00:00
commit 95a3a7277b
3 changed files with 30 additions and 2 deletions

View File

@ -246,6 +246,9 @@ impl FilteredTests {
}));
self.add_test(desc, testfn);
}
fn total_len(&self) -> usize {
self.tests.len() + self.benchs.len()
}
}
pub fn run_tests<F>(
@ -303,13 +306,13 @@ where
};
}
let filtered_out = tests_len - filtered.tests.len();
let filtered_out = tests_len - filtered.total_len();
let event = TestEvent::TeFilteredOut(filtered_out);
notify_about_test_event(event)?;
let shuffle_seed = get_shuffle_seed(opts);
let event = TestEvent::TeFiltered(filtered.tests.len(), shuffle_seed);
let event = TestEvent::TeFiltered(filtered.total_len(), shuffle_seed);
notify_about_test_event(event)?;
let concurrency = opts.test_threads.unwrap_or_else(get_concurrency);

View File

@ -0,0 +1,11 @@
include ../../run-make-fulldeps/tools.mk
# ignore-cross-compile
all:
# Smoke-test that `#[bench]` isn't entirely broken.
$(RUSTC) --test smokebench.rs -O
$(call RUN,smokebench --bench)
$(call RUN,smokebench --bench noiter)
$(call RUN,smokebench --bench yesiter)
$(call RUN,smokebench)

View File

@ -0,0 +1,14 @@
#![feature(test)]
extern crate test;
#[bench]
fn smoke_yesiter(b: &mut test::Bencher) {
let mut i = 0usize;
b.iter(|| {
i = i.wrapping_add(1);
i
})
}
#[bench]
fn smoke_noiter(_: &mut test::Bencher) {}