-
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
libtest - capture stderr from tests #40298
Comments
I agree on this. For a little more detail; Consider the following #[macro_use]
extern crate log;
fn do_stuff() -> bool {
println!("println");
error!("error");
true
}
#[test]
fn my_test() {
assert_eq!(true, do_stuff());
} run: actual output:
expected output:
|
Using |
@dpc Not sure it would help, since it seems |
@ martinlindhe ... Edited my original coment. Slog doesn't care. Log to stdout, stderr, file. Or even open new raw |
I actually should create |
@dpc, Okay.. so I can make a custom slog logger that outputs to stdout, thus allow cargo test to fetch the output. Gotcha. |
Yes, I agree. Not everyone is in a position to use slog, as awesome as it
is.
…On Fri, Mar 31, 2017, 15:36 Martin Lindhe ***@***.***> wrote:
@dpc <https://github.com/dpc>, Okay.. so I can make a custom slog logger
that outputs to stdout, thus allow cargo test to fetch the output. Gotcha.
But I think it would benefit the end user more if cargo test would display
stderr, even if it is hidden behind a rather obscure flag as --nocapture.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#40298 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADI0_dspanD5UUkSfN3CQYGj7A2WUYXLks5rrWPbgaJpZM4MUXd0>
.
|
Lays the groundwork for mitigating: - rust-lang#12309 - rust-lang#31983 - rust-lang#40298 - rust-lang#42474
Any updates on this? |
AFAIU libtest now captures "stderr" and "stdout" but does so in a way that isn't compatible with some loggers that try to use the standard stderr/stdout without using something like Another minor issue is that while libtest does capture |
Closing as duplicate of #42474. |
I'm currently having a problem with testing libraries that use
log
with eitherenv_logger
orflexi_logger
in their tests. In the "real world", they should log tostderr
, but libtest (and, by extension Cargo) doesn't capturestderr
from tests, so I have to jump through hoops to get these libraries to log tostdout
instead, or sift through huge logdumps.Would it be possible to capture
stderr
from tests?I originally posted this on the Cargo repo, but was told to file here. Possibly related to #31983, but I've tried limiting the test threads (
RUST_TEST_THREADS=1
) with no result.The text was updated successfully, but these errors were encountered: