Skip to content

Commit

Permalink
add tests on running benchmarks with -Z panic-abort-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed May 26, 2023
1 parent b82eb28 commit 142f453
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions tests/ui/test-attrs/test-panic-abort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -48,3 +52,8 @@ fn no_residual_environment() {
}
}
}

#[bench]
fn benchmark(b: &mut Bencher) {
b.iter(|| assert_eq!(1 + 1, 2));
}
7 changes: 4 additions & 3 deletions tests/ui/test-attrs/test-panic-abort.run.stdout
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,13 +19,13 @@ 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


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

0 comments on commit 142f453

Please sign in to comment.