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 upTracking issue for std::io::set_panic and set_print #31343
Comments
This comment has been minimized.
This comment has been minimized.
|
This is legacy behavior on behalf of libtest. The I don't think we should stabilize either of these (as evident by |
This comment has been minimized.
This comment has been minimized.
|
@DanielKeep was specifically interested in |
This comment has been minimized.
This comment has been minimized.
|
Currently, the code for doing this (replacing stdout) is platform-specific and really brittle (see Because of libstd's caching behaviour, the only way I can see to do this properly is to be able to explicitly replace the output writer. Also, consider that you often want to redirect stdout/stderr when working with GUI applications, either to an internal buffer or a log file. Remember that on Windows, GUI applications don't have the standard IO handles connected to anything. One point to note, however, is that the interception I'm doing is process-wide, whereas I believe fn set_process_stdout<W: Write + IntoRawFd>(write: W) -> io::Result<()> { ... }
fn set_thread_stdout<W: Write>(write: W) -> io::Result<()> { ... } |
steveklabnik
added
the
A-libs
label
Feb 2, 2016
This comment has been minimized.
This comment has been minimized.
|
The two functions in the original report were added as a short term hack and are not intended for stabilisation consideration. If the functionality is desired, an RFC with a proper proposal should be created IMO. |
This comment has been minimized.
This comment has been minimized.
|
If this is a short term hack, what will the |
This comment has been minimized.
This comment has been minimized.
What test crate is using is an implementation detail of (currently) internal component. I suppose test crate would start using the newly introduced stable functions once those become available. I do not argue against including this sort of functionality into libstd, but to me it sounds like there should be more design process for this and the process in question happens with RFCs (e.g. one obvious solution is to have something based on |
This comment has been minimized.
This comment has been minimized.
|
For the record, the stdout and stderr are ignored when running an Android app. EDIT: in fact no longer the case. |
This comment has been minimized.
This comment has been minimized.
BartMassey
commented
Jul 31, 2016
|
For the record, see issue #35136 for an example where the test runner fouls up my test via I would prefer to see |
BartMassey
referenced this issue
Jul 31, 2016
Open
Test runner interacts badly with redirected child process #35136
brson
added
the
B-unstable
label
Mar 1, 2017
steveklabnik
added
T-libs
and removed
A-libs
labels
Mar 24, 2017
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
SecondNature
commented
Jul 18, 2018
|
set_print() doesn't capture io through std::io::write(). Consider adding set_write() or perhaps making internal set_stdio() , if that would achieve the same result, public would provide io::write() capture. |
This comment has been minimized.
This comment has been minimized.
|
@SecondNature There is no |
This comment has been minimized.
This comment has been minimized.
SecondNature
commented
Jul 18, 2018
|
Yes std::io::write() doesn't exist. My mistake. std::writeln!() redirection is required. Can capture println!() with set_print() but can't capture std::writeln!() as no set_write(). |
This comment has been minimized.
This comment has been minimized.
|
The |
This comment has been minimized.
This comment has been minimized.
KodrAus
commented
Sep 24, 2018
|
We ran into a quirk of |
This comment has been minimized.
This comment has been minimized.
mcandre
commented
Dec 26, 2018
|
Would like to see these stabilized, so that Rust can produce CloudABI binaries without requiring nightly |
This comment has been minimized.
This comment has been minimized.
|
@mcandre Could you say more about how and why these functions are required for CloudABI? |
This comment has been minimized.
This comment has been minimized.
viftodi
commented
Feb 13, 2019
|
Hello, I think there is a huge difference between an "unstable" feauture such as set_print which has been basically unchanged for years and is used by cargo test and other experimental unstable feautures. I think either rust should allow certain unstable features to be used in stable as well with a warning, set_print being one example, or set_print should have the unstable removed. I really need this and it's really a shame that I can't do it at all in rust without being forced to use nightly |
This comment has been minimized.
This comment has been minimized.
SonnyX
commented
Apr 3, 2019
|
I would like to see a stabilized implementation of this so that libraries such as gag would be able to become cross-platform in a reliable way. |
SimonSapin commentedFeb 1, 2016
std::iocontains these two public unstable functions:They both have
#[doc(hidden)]. Anyone knows why?The also both have:
Their functionality is evidently useful, since the
testcrate uses them to capture the output of tests on only show it when they fail. External test harnesses would likely want to have similar functionality.This issue is about eventually stabilizing either these functions or a more general mechanism.
For
set_panic, that mechanism might be panic handlers (#30449) though it would be nice to be able to not duplicate most of the work done in the default handler just to change the output stream. This still leavesset_print.