]> git.proxmox.com Git - rustc.git/blame - src/test/ui/threads-sendsync/task-stderr.rs
New upstream version 1.50.0+dfsg1
[rustc.git] / src / test / ui / threads-sendsync / task-stderr.rs
CommitLineData
b7449926 1// run-pass
7453a54e
SL
2// ignore-emscripten no threads support
3
fc512014 4#![feature(internal_output_capture)]
1a4d82fc 5
c34b1796
AL
6use std::io;
7use std::str;
8use std::sync::{Arc, Mutex};
1a4d82fc
JJ
9use std::thread;
10
c34b1796
AL
11fn 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}