Closed robertwahler closed 1 year ago
The standard library's println
uses a semi-public-but-unstable API for the test
crate to capture output
See https://github.com/rust-lang/rust/blob/master/library/std/src/io/stdio.rs#L979
To support this, we'd need to special case print
/println
/eprint
/eprintln
to call the original if #[cfg(test)]
. This would require making some of the logic shuffled around to allow the logic to wrap around other macros and not just streams. The conditional behavior for the error handling should be preserved in the non-test case. As broken pipes for tests is likely to be a problem.
When running
anstream::println!("should this show?");
in a unit test, I would have thought that no output would show on stdout unless running the test viacargo test -- --nocapture
but it shows regardless of the no capture flag. I'm pretty new to rust so I may be missing something obvious. Thanks!