Closed
Description
I've filed this bug in rust-lang/cargo but I'm afraid rust-lang/rust is the correct repo for this.
I ran the tests for one of my crates that uses threads in its example code. I've noticed it printed some lines to stdout, even though --nocapture
wasn't set, but not all of them. It appears that text printed from new threads are not correctly captured, I think this is not intended.
Reproduce
#[cfg(test)]
mod tests {
use std::thread;
use std::time::Duration;
#[test]
fn it_works() {
thread::spawn(move || {
println!("request: {:?}", 123);
});
thread::sleep(Duration::from_secs(1));
println!("response: {:?}", 456);
}
Output
running 2 tests
request: 123
test tests::it_works ... ok
[...]
Meta
rustc --version --verbose
:
rustc 1.17.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.17.0
LLVM version: 4.0