]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
7453a54e SL |
2 | // ignore-emscripten no threads support |
3 | ||
fc512014 | 4 | #![feature(internal_output_capture)] |
1a4d82fc | 5 | |
c34b1796 AL |
6 | use std::io; |
7 | use std::str; | |
8 | use std::sync::{Arc, Mutex}; | |
1a4d82fc JJ |
9 | use std::thread; |
10 | ||
c34b1796 AL |
11 | fn main() { |
12 | let data = Arc::new(Mutex::new(Vec::new())); | |
fc512014 XL |
13 | let res = thread::Builder::new().spawn({ |
14 | let data = data.clone(); | |
15 | move || { | |
16 | io::set_output_capture(Some(data)); | |
17 | panic!("Hello, world!") | |
18 | } | |
85aaf69f | 19 | }).unwrap().join(); |
1a4d82fc JJ |
20 | assert!(res.is_err()); |
21 | ||
c34b1796 AL |
22 | let output = data.lock().unwrap(); |
23 | let output = str::from_utf8(&output).unwrap(); | |
85aaf69f | 24 | assert!(output.contains("Hello, world!")); |
1a4d82fc | 25 | } |