Skip to content
Prev Previous commit
Next Next commit
testutils: enable backtrace capture by default (RUST_BACKTRACE=1) in …
…tests

So backtraces are shown without requiring the environment variable.
  • Loading branch information
glehmann committed Mar 18, 2026
commit c9b89b37f0727fa4c1fe3706c842dfcef1c0e028
7 changes: 7 additions & 0 deletions lib/testutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ pub mod test_backend;

#[ctor::ctor]
fn init_color_eyre() {
// Enable backtrace capture by default in tests
if std::env::var("RUST_BACKTRACE").is_err() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Probably no action needed) I have two worries about this:

  • Can ctor support this on all systems? AFAIU, it's only supposed to use libc. OTOH, if this passes CI, it probably works.
  • I'm not 100% sure we want this. But it's probably better? I'm up for trying it and seeing if it makes anyone unhappy.

unsafe {
std::env::set_var("RUST_BACKTRACE", "1");
}
}

drop(
color_eyre::config::HookBuilder::default()
.add_frame_filter(Box::new(|frames| {
Expand Down