ensc_testsuite/util/
mod.rs1pub mod counter;
4pub mod status;
5pub mod result;
6
7thread_local! {
8 pub(crate) static PANIC_MSG: std::cell::RefCell<Option<String>> = std::cell::RefCell::default();
9}
10
11pub fn set_panic_msg(msg: &str)
12{
13 PANIC_MSG.with(|m| {
14 *m.borrow_mut() = Some(msg.to_string());
15 })
16}
17
18pub(crate) fn get_panic_msg() -> Option<String>
19{
20 PANIC_MSG.with(|m| {
21 (*m.borrow()).clone()
22 })
23}
24
25#[macro_export]
26macro_rules! test_panic{
27 ($msg:literal) => {
28 panic!(msg);
29 };
30
31 ($($arg:tt)*) => {{
32 let msg = std::fmt::format(format_args!($($arg)*));
33
34 $crate::util::set_panic_msg(&msg);
35
36 panic!($($arg)*);
37 }};
38}