diff options
| author | bors <bors@rust-lang.org> | 2022-10-31 18:50:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-31 18:50:06 +0000 |
| commit | 95a3a7277b44bbd2dd3485703d9a05f64652b60e (patch) | |
| tree | d025a9dd44178f689ba492b9a0e53c30418c5769 | |
| parent | 2afca78a0b03db144c5d8b9f8868feebfe096309 (diff) | |
| parent | bf88755f8892c1e42eccd302ed5b17716f669975 (diff) | |
| download | rust-95a3a7277b44bbd2dd3485703d9a05f64652b60e.tar.gz rust-95a3a7277b44bbd2dd3485703d9a05f64652b60e.zip | |
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
| -rw-r--r-- | library/test/src/lib.rs | 7 | ||||
| -rw-r--r-- | src/test/run-make/test-benches/Makefile | 11 | ||||
| -rw-r--r-- | src/test/run-make/test-benches/smokebench.rs | 14 |
3 files changed, 30 insertions, 2 deletions
diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 56a8d92f55d..f16d94bbc81 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -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); diff --git a/src/test/run-make/test-benches/Makefile b/src/test/run-make/test-benches/Makefile new file mode 100644 index 00000000000..8fc122515d0 --- /dev/null +++ b/src/test/run-make/test-benches/Makefile @@ -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) diff --git a/src/test/run-make/test-benches/smokebench.rs b/src/test/run-make/test-benches/smokebench.rs new file mode 100644 index 00000000000..ef5e5a62068 --- /dev/null +++ b/src/test/run-make/test-benches/smokebench.rs @@ -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) {} |
