Skip to content

Commit e93a049

Browse files
committed
test-uitls: fix test output not being captured by cargo test
Rust’s `libtest` has a… limitation where it doesn’t capture data written directly to `std::io::stdout` or `std::io::stderr` (see rust-lang/rust#90785). Since we are test logger to use the latter, none of the log messages are captured by the test harness. The solution is to use `TestWriter` as the writer instead which cooperates `libtest` better. Issue: near#4490
1 parent 8e933e9 commit e93a049

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test-utils/logger/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn setup_subscriber_from_filter(mut env_filter: EnvFilter) {
2020
let _ = tracing_subscriber::fmt::Subscriber::builder()
2121
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE)
2222
.with_env_filter(env_filter)
23-
.with_writer(std::io::stderr)
23+
.with_writer(tracing_subscriber::fmt::TestWriter::new())
2424
.try_init();
2525
}
2626

0 commit comments

Comments
 (0)