diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 56a8d92f55db2..f16d94bbc81c3 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( @@ -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 0000000000000..8fc122515d0a3 --- /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 0000000000000..ef5e5a6206847 --- /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) {}