libtest: Fix padding of benchmarks run as tests
Before this fix we applied padding before manually doing what `convert_benchmarks_to_tests()` does. Instead use `convert_benchmarks_to_tests()` if applicable and then apply padding afterwards so it becomes correct. (Benches should only be padded when run as benches to make it easy to compare the benchmark numbers.)
This commit is contained in:
parent
4db40579ba
commit
12e6bcfcab
@ -298,24 +298,18 @@ where
|
||||
|
||||
let mut filtered = FilteredTests { tests: Vec::new(), benches: Vec::new(), next_id: 0 };
|
||||
|
||||
for test in filter_tests(opts, tests) {
|
||||
let mut filtered_tests = filter_tests(opts, tests);
|
||||
if !opts.bench_benchmarks {
|
||||
filtered_tests = convert_benchmarks_to_tests(filtered_tests);
|
||||
}
|
||||
|
||||
for test in filtered_tests {
|
||||
let mut desc = test.desc;
|
||||
desc.name = desc.name.with_padding(test.testfn.padding());
|
||||
|
||||
match test.testfn {
|
||||
DynBenchFn(benchfn) => {
|
||||
if opts.bench_benchmarks {
|
||||
filtered.add_bench(desc, DynBenchFn(benchfn));
|
||||
} else {
|
||||
filtered.add_test(desc, DynBenchAsTestFn(benchfn));
|
||||
}
|
||||
}
|
||||
StaticBenchFn(benchfn) => {
|
||||
if opts.bench_benchmarks {
|
||||
filtered.add_bench(desc, StaticBenchFn(benchfn));
|
||||
} else {
|
||||
filtered.add_test(desc, StaticBenchAsTestFn(benchfn));
|
||||
}
|
||||
DynBenchFn(_) | StaticBenchFn(_) => {
|
||||
filtered.add_bench(desc, test.testfn);
|
||||
}
|
||||
testfn => {
|
||||
filtered.add_test(desc, testfn);
|
||||
|
@ -2,7 +2,7 @@
|
||||
# needs-unwind because #[bench] and -Cpanic=abort requires -Zpanic-abort-tests
|
||||
include ../tools.mk
|
||||
|
||||
NORMALIZE=sed 's%[0-9,]\+ ns/iter (+/- [0-9,]\+)%?? ns/iter (+/- ??)%' | sed 's%finished in [0-9\.]\+%finished in ??%'
|
||||
NORMALIZE=sed 's%[0-9,]\{1,\} ns/iter (+/- [0-9,]\{1,\})%?? ns/iter (+/- ??)%' | sed 's%finished in [0-9\.]\{1,\}%finished in ??%'
|
||||
|
||||
all:
|
||||
$(RUSTC) --test tests.rs
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
running 4 tests
|
||||
test short_bench_name ... ok
|
||||
test short_bench_name ... ok
|
||||
test short_test_name ... ok
|
||||
test this_is_a_really_long_bench_name ... ok
|
||||
test this_is_a_really_long_test_name ... ok
|
||||
|
Loading…
x
Reference in New Issue
Block a user