mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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:
commit
95a3a7277b
@ -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);
|
||||
|
11
src/test/run-make/test-benches/Makefile
Normal file
11
src/test/run-make/test-benches/Makefile
Normal 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)
|
14
src/test/run-make/test-benches/smokebench.rs
Normal file
14
src/test/run-make/test-benches/smokebench.rs
Normal 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) {}
|
Loading…
Reference in New Issue
Block a user