diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-08-04 18:42:36 -0700 |
|---|---|---|
| committer | Sergio Benitez <sb@sergio.bz> | 2020-10-22 18:15:44 -0700 |
| commit | d0d0e7820806bbb89a2733bae8f9aaa9c78345d0 (patch) | |
| tree | b7a7a24124c08c5da4fd25ab60b892d3b35bdacc /library/std/src/thread | |
| parent | 6b9fbf212a06944ff23325d2d63215805dc3c6c3 (diff) | |
| download | rust-d0d0e7820806bbb89a2733bae8f9aaa9c78345d0.tar.gz rust-d0d0e7820806bbb89a2733bae8f9aaa9c78345d0.zip | |
Capture output from threads spawned in tests
Fixes #42474.
Diffstat (limited to 'library/std/src/thread')
| -rw-r--r-- | library/std/src/thread/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 45c10266ba2..bdb8fc7807b 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -457,11 +457,16 @@ impl Builder { let my_packet: Arc<UnsafeCell<Option<Result<T>>>> = Arc::new(UnsafeCell::new(None)); let their_packet = my_packet.clone(); + let (stdout, stderr) = crate::io::clone_io(); + let main = move || { if let Some(name) = their_thread.cname() { imp::Thread::set_name(name); } + crate::io::set_print(stdout); + crate::io::set_panic(stderr); + // SAFETY: the stack guard passed is the one for the current thread. // This means the current thread's stack and the new thread's stack // are properly set and protected from each other. |
