Ancestors

Toot

Written by knutaf on 2025-01-19 at 04:51

i'm trying to add #tracing (like the crate called tracing) to my current #rust project. i'm using tracing-forest to get nested output for my spans, and i want to get that into all my 200+ tests, but i don't want to add a new line to every test. a single global initializer before all tests run would be great, or else a per-test initializer would be fine. i've found some partial solutions, but nothing that lets me use tracing-forest in a layer. any ideas what I could do?

=> More informations about this toot | More toots from knutaf@mastodon.gamedev.place

Descendants

Written by Marsh Ray on 2025-01-19 at 05:21

@knutaf I’m interested in this too.

Have you looked at the test-log crate?

=> More informations about this toot | More toots from marshray@infosec.exchange

Written by knutaf on 2025-01-19 at 06:30

@marshray yeah, I glanced at it. It doesn't seem to let me customize my subscriber, is the thing.

=> More informations about this toot | More toots from knutaf@mastodon.gamedev.place

Written by Marsh Ray on 2025-01-19 at 07:26

@knutaf I did some checking. Custom test frameworks show no sign of progress to becoming stable rust.

Whatever it is that crate is doing, you’ll probably have to repurpose or replicate it.

=> More informations about this toot | More toots from marshray@infosec.exchange

Written by Ben Kimock on 2025-01-22 at 06:30

@knutaf I think you are looking for https://crates.io/crates/ctor

=> More informations about this toot | More toots from saethlin@hachyderm.io

Written by knutaf on 2025-01-23 at 17:16

@saethlin thanks. i saw this but the restrictions seemed pretty serious, especially since i don't know what all the tracing code depends on. i suppose i could try to get a no-std version of it, but it felt limiting.

"The code that runs in the ctor and dtor functions should be careful to limit itself to libc functions and code that does not rely on Rust's stdlib services."

i ended up redefining my tests using a macro_rules that incorporates the tracing init code

=> More informations about this toot | More toots from knutaf@mastodon.gamedev.place

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113853220100454136
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
297.330054 milliseconds
Gemini-to-HTML Time
1.484641 milliseconds

This content has been proxied by September (3851b).