add tests on running benchmarks with -Z panic-abort-tests

This commit is contained in:
Pietro Albini 2023-05-26 12:56:51 +02:00
parent b82eb28224
commit 142f453758
No known key found for this signature in database
GPG Key ID: CD76B35F7734769E
2 changed files with 13 additions and 3 deletions

View File

@ -11,9 +11,13 @@
// ignore-sgx no subprocess support
#![cfg(test)]
#![feature(test)]
extern crate test;
use std::io::Write;
use std::env;
use test::Bencher;
#[test]
fn it_works() {
@ -48,3 +52,8 @@ fn no_residual_environment() {
}
}
}
#[bench]
fn benchmark(b: &mut Bencher) {
b.iter(|| assert_eq!(1 + 1, 2));
}

View File

@ -1,5 +1,6 @@
running 5 tests
running 6 tests
test benchmark ... ok
test it_exits ... FAILED
test it_fails ... FAILED
test it_panics - should panic ... ok
@ -18,7 +19,7 @@ testing123
testing321
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `2`,
right: `5`', $DIR/test-panic-abort.rs:34:5
right: `5`', $DIR/test-panic-abort.rs:38:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@ -26,5 +27,5 @@ failures:
it_exits
it_fails
test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
test result: FAILED. 4 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME