about summary refs log tree commit diff
path: root/library/test/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-27 11:43:18 +0000
committerbors <bors@rust-lang.org>2020-10-27 11:43:18 +0000
commit56d288fa46e04cd5faf53d369a1a640a97e2bb08 (patch)
treec2f7e816a443a91a45a9038ce7ecc46ede60f97c /library/test/src
parent20b1e05a8d0e1773dc840a3286aa37916e87d84b (diff)
parent7c4fe002131f1160f2054885ab40c74464951a64 (diff)
downloadrust-56d288fa46e04cd5faf53d369a1a640a97e2bb08.tar.gz
rust-56d288fa46e04cd5faf53d369a1a640a97e2bb08.zip
Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
Capture output from threads spawned in tests

This is revival of #75172.

Original text:
> Fixes #42474.
>
> r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore.

---

Closes #75172.
Diffstat (limited to 'library/test/src')
-rw-r--r--library/test/src/helpers/sink.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/test/src/helpers/sink.rs b/library/test/src/helpers/sink.rs
index aa7fe248773..dfbf0a3b72f 100644
--- a/library/test/src/helpers/sink.rs
+++ b/library/test/src/helpers/sink.rs
@@ -6,6 +6,7 @@ use std::{
     sync::{Arc, Mutex},
 };
 
+#[derive(Clone)]
 pub struct Sink(Arc<Mutex<Vec<u8>>>);
 
 impl Sink {
@@ -14,6 +15,12 @@ impl Sink {
     }
 }
 
+impl io::LocalOutput for Sink {
+    fn clone_box(&self) -> Box<dyn io::LocalOutput> {
+        Box::new(self.clone())
+    }
+}
+
 impl Write for Sink {
     fn write(&mut self, data: &[u8]) -> io::Result<usize> {
         Write::write(&mut *self.0.lock().unwrap(), data)