From f3b52fdb74f82c36b57053a41ec2f6d2300265a5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 16 Jun 2023 12:17:33 +0200 Subject: [PATCH] make test work cross-platform --- .../panic/thread_local_const_drop_panic.rs | 5 +++++ .../thread_local_const_drop_panic.stderr | 22 +------------------ .../fail/panic/thread_local_drop_panic.rs | 3 +++ .../fail/panic/thread_local_drop_panic.stderr | 11 +--------- 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.rs b/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.rs index 53d169967fa7f..93ad42ea1cced 100644 --- a/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.rs +++ b/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.rs @@ -1,4 +1,9 @@ //@error-in-other-file: aborted execution +// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing. +// Full backtraces avoid annoying empty line differences. +//@compile-flags: -Zmiri-backtrace=full +//@normalize-stderr-test: "'main'|''" -> "$$NAME" +//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> "" pub struct NoisyDrop {} diff --git a/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.stderr b/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.stderr index 122af7babe5a4..47962e44adf64 100644 --- a/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/thread_local_const_drop_panic.stderr @@ -1,26 +1,6 @@ -thread '' panicked at 'ow', $DIR/thread_local_const_drop_panic.rs:LL:CC -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread $NAME panicked at 'ow', $DIR/thread_local_const_drop_panic.rs:LL:CC fatal runtime error: thread local panicked on drop error: abnormal termination: the program aborted execution - --> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC - | -LL | unsafe { libc::abort() } - | ^^^^^^^^^^^^^ the program aborted execution - | - = note: inside `std::sys::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC - = note: inside `::drop` at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::ptr::drop_in_place:: - shim(Some(std::thread::local_impl::abort_on_dtor_unwind::DtorUnwindGuard))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC - = note: inside `RUSTLIB/std/src/sys/PLATFORM/thread_local/fast_local.rs:LL:CC]>` at RUSTLIB/std/src/sys/PLATFORM/thread_local/mod.rs:LL:CC -note: inside `NOISY::__getit::destroy` - --> $DIR/thread_local_const_drop_panic.rs:LL:CC - | -LL | / thread_local! { -LL | | pub static NOISY: NoisyDrop = const { NoisyDrop {} }; -LL | | } - | |_^ - = note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace error: aborting due to previous error diff --git a/src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs b/src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs index 7880aeff10363..107d70a3b3c7f 100644 --- a/src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs +++ b/src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs @@ -1,4 +1,7 @@ //@error-in-other-file: aborted execution +// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing +//@normalize-stderr-test: "'main'|''" -> "$$NAME" +//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> "" pub struct NoisyDrop {} diff --git a/src/tools/miri/tests/fail/panic/thread_local_drop_panic.stderr b/src/tools/miri/tests/fail/panic/thread_local_drop_panic.stderr index 6b6627331b4e5..2a56e2b9c877a 100644 --- a/src/tools/miri/tests/fail/panic/thread_local_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/thread_local_drop_panic.stderr @@ -1,15 +1,6 @@ -thread '' panicked at 'ow', $DIR/thread_local_drop_panic.rs:LL:CC -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread $NAME panicked at 'ow', $DIR/thread_local_drop_panic.rs:LL:CC fatal runtime error: thread local panicked on drop error: abnormal termination: the program aborted execution - --> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC - | -LL | unsafe { libc::abort() } - | ^^^^^^^^^^^^^ the program aborted execution - | - = note: inside `std::sys::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC - = note: inside `std::sys::PLATFORM::thread_local::fast_local::destroy_value::` at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::sys_common::thread_local_dtor::register_dtor_fallback::run_dtors` at RUSTLIB/std/src/sys_common/thread_local_dtor.rs:LL:CC error: aborting due to previous error