add tests for both kinds of unwind-terminate messages
This commit is contained in:
parent
114fde6ac7
commit
af29a26378
@ -100,14 +100,17 @@ fn runtest(me: &str) {
|
||||
let s = str::from_utf8(&out.stderr).unwrap();
|
||||
// loosened the following from double::h to double:: due to
|
||||
// spurious failures on mac, 32bit, optimized
|
||||
assert!(s.contains("stack backtrace") && contains_verbose_expected(s, "double"),
|
||||
"bad output3: {}", s);
|
||||
assert!(
|
||||
s.contains("stack backtrace") &&
|
||||
s.contains("panic in a destructor during cleanup") &&
|
||||
contains_verbose_expected(s, "double"),
|
||||
"bad output3: {}", s
|
||||
);
|
||||
|
||||
// Make sure a stack trace isn't printed too many times
|
||||
//
|
||||
// Currently it is printed 3 times ("once", "twice" and "panic in a
|
||||
// function that cannot unwind") but in the future the last one may be
|
||||
// removed.
|
||||
// Currently it is printed 3 times ("once", "twice" and "panic in a destructor during
|
||||
// cleanup") but in the future the last one may be removed.
|
||||
let p = template(me).arg("double-fail")
|
||||
.env("RUST_BACKTRACE", "1").spawn().unwrap();
|
||||
let out = p.wait_with_output().unwrap();
|
||||
|
19
tests/ui/panics/panic-in-cleanup.rs
Normal file
19
tests/ui/panics/panic-in-cleanup.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// run-fail
|
||||
// check-run-results
|
||||
// error-pattern: panic in a destructor during cleanup
|
||||
// normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
|
||||
// normalize-stderr-test: "\n +at [^\n]+" -> ""
|
||||
// ignore-emscripten no processes
|
||||
|
||||
struct Bomb;
|
||||
|
||||
impl Drop for Bomb {
|
||||
fn drop(&mut self) {
|
||||
panic!("BOOM");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _b = Bomb;
|
||||
panic!();
|
||||
}
|
10
tests/ui/panics/panic-in-cleanup.run.stderr
Normal file
10
tests/ui/panics/panic-in-cleanup.run.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
thread 'main' panicked at $DIR/panic-in-cleanup.rs:18:5:
|
||||
explicit panic
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
thread 'main' panicked at $DIR/panic-in-cleanup.rs:12:9:
|
||||
BOOM
|
||||
stack backtrace:
|
||||
thread 'main' panicked at library/core/src/panicking.rs:126:5:
|
||||
panic in a destructor during cleanup
|
||||
stack backtrace:
|
||||
thread caused non-unwinding panic. aborting.
|
15
tests/ui/panics/panic-in-ffi.rs
Normal file
15
tests/ui/panics/panic-in-ffi.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// run-fail
|
||||
// check-run-results
|
||||
// error-pattern: panic in a function that cannot unwind
|
||||
// normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
|
||||
// normalize-stderr-test: "\n +at [^\n]+" -> ""
|
||||
// ignore-emscripten no processes
|
||||
#![feature(c_unwind)]
|
||||
|
||||
extern "C" fn panic_in_ffi() {
|
||||
panic!("Test");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
panic_in_ffi();
|
||||
}
|
7
tests/ui/panics/panic-in-ffi.run.stderr
Normal file
7
tests/ui/panics/panic-in-ffi.run.stderr
Normal file
@ -0,0 +1,7 @@
|
||||
thread 'main' panicked at $DIR/panic-in-ffi.rs:10:5:
|
||||
Test
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
thread 'main' panicked at library/core/src/panicking.rs:126:5:
|
||||
panic in a function that cannot unwind
|
||||
stack backtrace:
|
||||
thread caused non-unwinding panic. aborting.
|
Loading…
x
Reference in New Issue
Block a user