`set_override` doesn't react immediately
neepl opened this issue · comments
neepl commented
Hi! I'm using set_override
to disable color output for my tests at their start and use unset_override
at their end. Time to time tests could fail. The reason is I'm still getting colored output. Could this issue be related to Ordering::Relaxed
memory ordering used in override methods?
Spenser Black commented
Since tests are run in parallel, you're likely hitting a race condition. A few ways to work around that could include
- setting an environment variable to disable coloring instead
- Combining all tests that set/unset the override into one test so that they don't interfere with each other
- Use a mutex to force the tests that set/unset override to wait on each other
- I think
cargo test --jobs 1
would force only 1 test to run at a time
neepl commented
Thanks, probably missed that my tests are running in parallel. I've already fixed this with recommendation from colored's crate page: use "colored/no-color" feature for test.