Test output capture does not capture Command output #92370
Labels
A-libtest
Area: `#[test]` / the `test` library
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: nothing should be printed to STDOUT for
cargo test
, while "hello" and "world" should be printed to STDOUT withcargo test -- --nocapture
.Instead, this happened: "world" is always printed to STDOUT (playground).
Meta
rustc --version --verbose
:The issue also occurs on nightly.
Notes
This happens because the output capture hook used by libtest only affects things that go through
print_to
:rust/library/std/src/io/stdio.rs
Line 1167 in 442248d
It's already known that libtest output capturing has some... inconsistencies (e.g., #12309, #90785, #35136), but in this particular case I wonder if it's possible to do something about it since
std
controls the defaults forCommand
. Specifically, it might make sense to haveCommand
default to a capturing.stdout
and.stderr
when those aren't overwritten in the builder.The text was updated successfully, but these errors were encountered: