-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Test runner interacts badly with redirected child process #35136
Comments
There is a hidden functionality ( |
Good to know; I looked for something like that, but never found it. Guess I wasn't looking carefully enough. Thanks much! I don't quite understand what I should do about this, though? I dug around in For now, I guess I'll use |
I'm not sure that there's much to be done here. The test runner does grab stdout by default, and I don't think that's going to change. Tests, I think, can call something along the lines of |
I think maybe you could provide functionality that allows a test to re-grab the old stdout temporarily? It would require saving it somewhere. Perhaps some sort of "with" closure? |
Hm, yeah, I think it's possible. I'll reopen; cc @rust-lang/libs, would we be interested in an API (probably in libtest) that allowed temporarily returning stdout/stderr for a given test? We could just have a |
That would be great! I think I'd prefer the closure to |
I dislike the weird stdout capturing logic in general and hope we can kill it off entirely someday specifically because it's magical and doesn't compose with child threads or processes. |
I'm actually only marginally sure what dumping |
(Moved here from rust-lang/cargo/2936 as it is believed to be a standard library bug.)
Consider the code at https://gitlab.com/BartMassey/ptyknot/tree/pipes-direct/misc/piperef-rs . The relevant portion is in piperef.rs:
This code is run in a child process. When it is invoked by running it after
cargo build
, it works fine regardless of whether Macro or C mode is used. When it is invoked bycargo test
, C mode works but Macro mode fails with an empty string. When it is invoked bycargo test -- --nocapture
, both modes work again. Here's a transcript:It looks like the test runner is fouling up the environment somehow, but I can't figure out how by looking at stuff.
The text was updated successfully, but these errors were encountered: