rust/library/test/src
Tal Gelbard 92ebf60b3b Drop panic hook after running tests
Previously we left the panic hook we allocated
on main termination. Doing so makes Valgrind
report it as a reachable unfreed block.
In order to fix that use `panic::take_hook()` before
examining test results.

Example backtrace:
```
==146594== 16 bytes in 1 blocks are still reachable in loss record 1 of 1
==146594==    at 0x4A390C5: malloc (vg_replace_malloc.c:442)
==146594==    by 0x151336: alloc (alloc.rs:98)
==146594==    by 0x151336: alloc_impl (alloc.rs:181)
==146594==    by 0x151336: allocate (alloc.rs:241)
==146594==    by 0x151336: exchange_malloc (alloc.rs:330)
==146594==    by 0x151336: new<test::test_main::{closure_env#0}> (boxed.rs:217)
==146594==    by 0x151336: test::test_main (lib.rs:124)
==146594==    by 0x1522F9: test::test_main_static (lib.rs:160)
==146594==    by 0x11E102: reachable_block_with_cargo_test::main (lib.rs:1)
==146594==    by 0x11EABA: core::ops::function::FnOnce::call_once (function.rs:250)
==146594==    by 0x11E76D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:154)
==146594==    by 0x11DFC0: std::rt::lang_start::{{closure}} (rt.rs:166)
==146594==    by 0x177D3A: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:284)
==146594==    by 0x177D3A: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:504)
==146594==    by 0x177D3A: try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:468)
==146594==    by 0x177D3A: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:142)
==146594==    by 0x177D3A: {closure#2} (rt.rs:148)
==146594==    by 0x177D3A: do_call<std::rt::lang_start_internal::{closure_env#2}, isize> (panicking.rs:504)
==146594==    by 0x177D3A: try<isize, std::rt::lang_start_internal::{closure_env#2}> (panicking.rs:468)
==146594==    by 0x177D3A: catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> (panic.rs:142)
==146594==    by 0x177D3A: std::rt::lang_start_internal (rt.rs:148)
==146594==    by 0x11DF99: std::rt::lang_start (rt.rs:165)
```

Signed-off-by: Tal Gelbard <talgelbard1@gmail.com>
2024-04-06 18:56:22 +03:00
..
formatters Rust is a proper name: rust → Rust 2024-03-07 07:49:22 +01:00
helpers Use generic NonZero everywhere else. 2024-02-22 15:17:34 +01:00
stats mv std libs to library/ 2020-07-27 19:51:13 -05:00
term remove redundant imports 2023-12-10 10:56:22 +08:00
bench.rs Do not panic when a test function returns Result::Err. 2022-09-16 14:36:00 +00:00
cli.rs libtest: Improve error when missing -Zunstable-options 2023-05-24 11:18:20 -05:00
console.rs Remove unused fields in some structures 2024-03-12 10:59:40 +01:00
event.rs Do fewer passes and generally be more efficient when filtering tests 2022-10-27 21:34:56 -04:00
lib.rs Drop panic hook after running tests 2024-04-06 18:56:22 +03:00
options.rs derive Default trait for compiletest::common::Config 2023-05-20 14:40:46 +03:00
stats.rs Fix naming format of IEEE 754 standard 2022-09-11 04:13:33 +02:00
term.rs WinConsole::new is not actually fallible 2022-10-21 12:18:33 +02:00
test_result.rs Actually abort in panic-abort-tests 2024-01-30 18:19:49 -08:00
tests.rs remove redundant imports 2023-12-10 10:56:22 +08:00
time.rs Fix uninlined_format_args in libtest 2022-12-19 08:58:40 +01:00
types.rs Rust is a proper name: rust → Rust 2024-03-07 07:49:22 +01:00