-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capturing stdout from test code is inconsistent #12309
Comments
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. |
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 is still true today with |
Nominating for 1.0-beta P-backcompat-libs. We need to finalize our capture story. |
1.0 beta, P-backcompat-libs, I-needsdecision |
triage: (1.0) |
triage: P-high (1.0) |
Rust *should* be swallowing all stdout output during test runs, but for some reason it isn't. This appears to be due to rust-lang/rust#12309. However, we can't have out test suite spam to the point of unreadability until that's fixed, so let's just not output from migrations during tests. This was paired, so it has been committed without PR. Fixes #156.
Rust *should* be swallowing all stdout output during test runs, but for some reason it isn't. This appears to be due to rust-lang/rust#12309. However, we can't have out test suite spam to the point of unreadability until that's fixed, so let's just not output from migrations during tests. This was paired, so it has been committed without PR. Fixes #156.
Rust *should* be swallowing all stdout output during test runs, but for some reason it isn't. This appears to be due to rust-lang/rust#12309. However, we can't have out test suite spam to the point of unreadability until that's fixed, so let's just not output from migrations during tests. This was paired, so it has been committed without PR. Fixes #156.
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. |
@alexcrichton just an idea, but how about we use something like |
@nagisa Can't use |
@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. |
@nagisa If Rust didn't cache the result of |
@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. |
@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. |
Lays the groundwork for mitigating: - rust-lang#12309 - rust-lang#31983 - rust-lang#40298 - rust-lang#42474
Going to go ahead and close this as a duplicate of #42474. |
fix: Fix incorrect expected type in completions for trailing match arms Fixes rust-lang/rust-analyzer#12264
I suggest that this issue be reopened. It has not been fixed, and there is no explanation for why it should not be considered further, either above or in the linked issue. I believe it is a current best practice to use |
I think this is the issue to keep open; #42474 is "fixed" in that output is now captured. It is just "inconsistent". FWIW, there will always be a way "around" it (talking to For child processes, there would need to be some file descriptor/handle juggling in |
The docs for
I don't think that can get an asterisk for "unless running from a |
@Mark-Simulacrum Please re-open, this is not actually a duplicate, and the problem still persists. |
@Mark-Simulacrum Please re-open, this is not actually a duplicate, and the problem still persists. If not fixed, this should at least be on the documentation. |
#90785 appears to be the current issue tracking this. |
fix: make `#[allow]` work on field for `pub_underscore_fields` Closes rust-lang#12286 changelog: `#[allow(clippy::pub_underscore_fields)]` now works on linted field
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.
The text was updated successfully, but these errors were encountered: