Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCapturing stdout from test code is inconsistent #12309
Comments
This comment has been minimized.
This comment has been minimized.
|
In my opinion, the only real bug here is that the child task's println isn't captured. Capturing stdout/stderr is not supposed to be comprehensive, it's supposed to clean up the output. You'll almost always be able to subvert whatever capturing is going on, it's not supposed to be exhaustive. |
This comment has been minimized.
This comment has been minimized.
|
Ok, so If the task-local one is still going to be named "stdout", then I think the documentation will need to be updated in a lot of places to make it explicit which "stdout" is being used. For instance, the documentation of Once that distinction is clear, it's natural to assume that child processes will inherit the process global FD, so I see why that's not a bug. It's easy enough to capture the output and print it to the task's "stdout". |
This comment has been minimized.
This comment has been minimized.
|
This is still true today with |
steveklabnik
added
the
A-libs
label
Jan 23, 2015
This comment has been minimized.
This comment has been minimized.
|
Nominating for 1.0-beta P-backcompat-libs. We need to finalize our capture story. |
aturon
added
the
I-nominated
label
Feb 16, 2015
This comment has been minimized.
This comment has been minimized.
|
1.0 beta, P-backcompat-libs, I-needsdecision |
pnkfelix
added this to the 1.0 beta milestone
Feb 19, 2015
pnkfelix
added
I-needs-decision
P-backcompat-libs
and removed
I-nominated
labels
Feb 19, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: (1.0) |
This comment has been minimized.
This comment has been minimized.
|
triage: P-high (1.0) |
rust-highfive
added
P-medium
and removed
P-backcompat-libs
labels
Mar 24, 2015
rust-highfive
modified the milestones:
1.0,
1.0 beta
Mar 24, 2015
alexcrichton
self-assigned this
Apr 2, 2015
steveklabnik
removed this from the 1.0 milestone
May 21, 2015
mfpiccolo
referenced this issue
Jan 31, 2016
Closed
[SQLite] Running our test suite spams the console with migration messages #156
sgrif
added a commit
to diesel-rs/diesel
that referenced
this issue
Jan 31, 2016
sgrif
added a commit
to diesel-rs/diesel
that referenced
this issue
Feb 3, 2016
sgrif
added a commit
to diesel-rs/diesel
that referenced
this issue
Feb 3, 2016
This comment has been minimized.
This comment has been minimized.
|
I also stumbled over this issue when starting a test server as a child process. The stdout logged by the server does not get captured. While I could redirect the output to /dev/null, that makes it hard to debug problems. On the other hand, allowing the stdout to be printed causes pages of unnecessary output, making it hard to see the actual test results. |
brson
added
P-low
T-libs
and removed
P-medium
labels
Oct 20, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton just an idea, but how about we use something like |
This comment has been minimized.
This comment has been minimized.
|
@nagisa Can't use |
This comment has been minimized.
This comment has been minimized.
|
@nagisa sounds plausible to me, I think there may also be ways to muck around with this on Windows as well. We'd likely still need to fiddle with private APIs in the standard library, however, as on Windows at least we cache the handles returned by the system so if they're reset we'd have to bust that cache. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@nagisa If Rust didn't cache the result of |
ghost
referenced this issue
Dec 19, 2016
Closed
Drain on root logger should not require 'static. #95
alexcrichton
removed their assignment
Feb 16, 2017
steveklabnik
removed
the
A-libs
label
Mar 24, 2017
Mark-Simulacrum
added
the
A-libtest
label
Jun 20, 2017
alexcrichton
referenced this issue
Jun 25, 2017
Closed
[test] Output of subprocesses is lost when not using RUST_TEST_NOCAPTURE=1 #42814
Mark-Simulacrum
added
C-enhancement
and removed
I-needs-decision
labels
Jul 20, 2017
azriel91
referenced this issue
Dec 25, 2017
Open
`cargo test` doesn't capture print from threads #42474
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Feb 17, 2018
•
|
@alexcrichton: these many reports and suggestions for improvement can be circumvented by removing the whole output capturing code and instead optionally report test outcomes as JSON messages on stdout, and assume tests themselves do not pollute stdout. Then we’d be done with these annoyances without putting in effort to unbreak output capturing. Are you open to a PR? Also, this issue should be moved to the Cargo issue tracker. |
This comment has been minimized.
This comment has been minimized.
|
@sanmai-NL I think that such a PR would unfortunately be a breaking change and as a result needs to be considered a little more carefully (e.g. with the dev-tools team). This is still a rustc issue as-is so I don't think it should move. |
MicahChalmer commentedFeb 16, 2014
The feature that captures "stdout" for tests doesn't capture all the ways that a test could print to stdout.
Only the first
println!call gets captured--the rest appear intermingled with the test output:It would be nice if all of these got captured.