From 2cc4b2ef6d9f344bc9c70f0decc963a5e3d26746 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 22 May 2024 14:16:33 +0200 Subject: [PATCH] Use add_spawn_hook for libtest's output capturing. --- std/src/thread/mod.rs | 4 ---- test/src/lib.rs | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/std/src/thread/mod.rs b/std/src/thread/mod.rs index ee8d688398d2c..c6b1e0de84cf5 100644 --- a/std/src/thread/mod.rs +++ b/std/src/thread/mod.rs @@ -502,9 +502,6 @@ impl Builder { }); let their_packet = my_packet.clone(); - let output_capture = crate::io::set_output_capture(None); - crate::io::set_output_capture(output_capture.clone()); - // Pass `f` in `MaybeUninit` because actually that closure might *run longer than the lifetime of `F`*. // See for more details. // To prevent leaks we use a wrapper that drops its contents. @@ -542,7 +539,6 @@ impl Builder { imp::Thread::set_name(name); } - crate::io::set_output_capture(output_capture); for hook in hooks { hook(); } diff --git a/test/src/lib.rs b/test/src/lib.rs index 30ccfe2af8dbd..00a0b55c6a9f9 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -24,6 +24,7 @@ #![feature(process_exitcode_internals)] #![feature(panic_can_unwind)] #![feature(test)] +#![feature(thread_spawn_hook)] #![allow(internal_features)] #![warn(rustdoc::unescaped_backticks)] @@ -134,6 +135,16 @@ pub fn test_main(args: &[String], tests: Vec, options: Option