Skip to content

Commit 4db4057

Browse files
committed
libtest: Add regression tests for padding
As you can see the padding is wrong when running benches as tests. This will be fixed in the next commit. (Benches should only be padded when run as benches to make it easy to compare the benchmark numbers.)
1 parent 64d7e0d commit 4db4057

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ignore-cross-compile because we run the compiled code
2+
# needs-unwind because #[bench] and -Cpanic=abort requires -Zpanic-abort-tests
3+
include ../tools.mk
4+
5+
NORMALIZE=sed 's%[0-9,]\+ ns/iter (+/- [0-9,]\+)%?? ns/iter (+/- ??)%' | sed 's%finished in [0-9\.]\+%finished in ??%'
6+
7+
all:
8+
$(RUSTC) --test tests.rs
9+
10+
$(call RUN,tests) --test-threads=1 | $(NORMALIZE) > "$(TMPDIR)"/test.stdout
11+
$(RUSTC_TEST_OP) "$(TMPDIR)"/test.stdout test.stdout
12+
13+
$(call RUN,tests) --test-threads=1 --bench | $(NORMALIZE) > "$(TMPDIR)"/bench.stdout
14+
$(RUSTC_TEST_OP) "$(TMPDIR)"/bench.stdout bench.stdout
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
running 4 tests
3+
test short_test_name ... ignored
4+
test this_is_a_really_long_test_name ... ignored
5+
test short_bench_name ... bench: ?? ns/iter (+/- ??)
6+
test this_is_a_really_long_bench_name ... bench: ?? ns/iter (+/- ??)
7+
8+
test result: ok. 0 passed; 0 failed; 2 ignored; 2 measured; 0 filtered out; finished in ??s
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
running 4 tests
3+
test short_bench_name ... ok
4+
test short_test_name ... ok
5+
test this_is_a_really_long_bench_name ... ok
6+
test this_is_a_really_long_test_name ... ok
7+
8+
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in ??s
9+
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(test)]
2+
extern crate test;
3+
4+
#[test]
5+
fn short_test_name() {}
6+
7+
#[test]
8+
fn this_is_a_really_long_test_name() {}
9+
10+
#[bench]
11+
fn short_bench_name(b: &mut test::Bencher) {
12+
b.iter(|| 1);
13+
}
14+
15+
#[bench]
16+
fn this_is_a_really_long_bench_name(b: &mut test::Bencher) {
17+
b.iter(|| 1);
18+
}

0 commit comments

Comments
 (0)