2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2024-03-06 20:19:20 +00:00
|
|
|
//@ needs-threads
|
2021-12-03 15:32:51 +00:00
|
|
|
//@ needs-unwind
|
2016-02-11 11:34:41 +00:00
|
|
|
|
2020-11-03 23:11:14 +00:00
|
|
|
#![feature(internal_output_capture)]
|
2015-01-08 01:25:56 +00:00
|
|
|
|
2015-03-11 22:24:14 +00:00
|
|
|
use std::sync::{Arc, Mutex};
|
2024-08-24 03:32:52 +00:00
|
|
|
use std::{io, str, thread};
|
2014-06-17 21:48:54 +00:00
|
|
|
|
2015-03-11 22:24:14 +00:00
|
|
|
fn main() {
|
|
|
|
let data = Arc::new(Mutex::new(Vec::new()));
|
2024-08-24 03:32:52 +00:00
|
|
|
let res = thread::Builder::new()
|
|
|
|
.spawn({
|
|
|
|
let data = data.clone();
|
|
|
|
move || {
|
|
|
|
io::set_output_capture(Some(data));
|
|
|
|
panic!("Hello, world!")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
.join();
|
2014-06-17 21:48:54 +00:00
|
|
|
assert!(res.is_err());
|
|
|
|
|
2015-03-11 22:24:14 +00:00
|
|
|
let output = data.lock().unwrap();
|
|
|
|
let output = str::from_utf8(&output).unwrap();
|
2015-01-27 02:21:15 +00:00
|
|
|
assert!(output.contains("Hello, world!"));
|
2014-06-17 21:48:54 +00:00
|
|
|
}
|