]> git.lizzy.rs Git - rust.git/blob - tests/ui/threads-sendsync/task-stderr.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / threads-sendsync / task-stderr.rs
1 // run-pass
2 // ignore-emscripten no threads support
3 // needs-unwind
4
5 #![feature(internal_output_capture)]
6
7 use std::io;
8 use std::str;
9 use std::sync::{Arc, Mutex};
10 use std::thread;
11
12 fn main() {
13     let data = Arc::new(Mutex::new(Vec::new()));
14     let res = thread::Builder::new().spawn({
15         let data = data.clone();
16         move || {
17             io::set_output_capture(Some(data));
18             panic!("Hello, world!")
19         }
20     }).unwrap().join();
21     assert!(res.is_err());
22
23     let output = data.lock().unwrap();
24     let output = str::from_utf8(&output).unwrap();
25     assert!(output.contains("Hello, world!"));
26 }