Getting stdout/stderr from failed tests

When tests fail, in particular for network crates, getting the logging history of the test run is immensely helpful. At some point this year something changed with cargo test so that I don’t get the logs anymore:

cargo test --all-features -- compat

runs only two tests (in this example) and shows the logged output (RUST_LOG=debug and using newest tracing and tracing_subscriber). If I leave off the compat filter (resulting in 14 tests run), the output is no longer shown. I found no command line argument to change this behaviour, and I’d like to instruct CI to always show the logs so that I can debug failures.

Does anyone have a clue where I might start searching for an answer?

Ah, dammit — I found it right after posting (but leaving here for others to find): I had changed the .init() call of the tracing subscriber in some tests but not others, so the first one won — and this was not deterministically one of the “correct” ones.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.