Skip to content

Commit

Permalink
test: fix miri failure due to tracing deps
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jul 30, 2022
1 parent 8253fb3 commit a43f883
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions cordyceps/src/list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,28 @@ fn const_new() {
const _: List<Entry> = List::new();
}

fn trace_init() -> tracing::dispatcher::DefaultGuard {
use tracing_subscriber::prelude::*;
tracing_subscriber::fmt()
.with_test_writer()
.with_max_level(tracing::Level::TRACE)
.with_target(false)
.with_timer(())
.set_default()
fn trace_init() -> impl Drop {
// XXX(eliza): unfortunately, attempting to set the default `tracing`
// subscriber inside of a Miri test makes Miri angry, because `tracing` uses
// `once_cell` internally, and `once_cell` apparently does a Naughty and
// Evil int-to-ptr cast. Sigh.
//
// re-enable this with Miri when `once_cell` is fixed.
#[cfg(not(miri))]
{
use tracing_subscriber::prelude::*;
tracing_subscriber::fmt()
.with_test_writer()
.with_max_level(tracing::Level::TRACE)
.with_target(false)
.with_timer(())
.set_default()
}

// Return an empty `Vec` when Miri is enabled: it has a `Drop` impl but
// doesn't actually *do* anything.
#[cfg(miri)]
Vec::<()>::new()
}

#[test]
Expand Down

0 comments on commit a43f883

Please sign in to comment.