d-e-s-o/test-log

Make Default Log Filter Parallel-Friendly

Opened this issue · 4 comments

Issue

Make default_log_filter stable by implementing a parallel-friendly way to manage environment variables.

Proposed Solution

The commit putting the default_log_filter attribute behind the "unstable" feature is awesome, but to get things stable, we could look to sealed-test, which solves the problem by forking unit tests into separate processes.

The shortcomings of sealed-test are that it doesn't support async and hasn't been updated in a while.

It's certainly a possibility, but I am not really in favor of such a heavy weight approach. I am pretty sure it will come with all sorts of gotchas (e.g., from the looks of it we'd be in for platform specific logic, meaning that we may exclude some unsupported platforms outright and just generally open whatever can of worms that entails) and suddenly a crate intending to initialize some logging bits influences your test execution behavior in weird ways.

My view is that there is a path to making this functionality race-free and with that stable-friendly, and that's with global attribute support. As such, I'd think it would be best if we exert effort on this front.

I don't like how heavyweight this approach is either, but what what other paths do you see?

I just noticed that temp-env uses a mutex to block concurrent testing:

Note that the crate makes use of a singleton mutex to avoid side effects between concurrently running tests. This may impact the degree of concurrency in your test execution.

Losing parallel tests would be pretty sad for this library, though, since the mutex lock on RUST_LOG would make every test serial. 😢

I don't like how heavyweight this approach is either, but what what other paths do you see?

Stable global attributes