How to limit the number of test threads in Cargo.toml?
I have tests that share a common resource and cannot run concurrently. These tests fail with cargo test
, but work with RUST_TEST_THREADS=1 cargo test
.
I can modify the tests to wait for a global mutex, but I don't want to clutter them up if there is an easier way to force cargo
this environment variable to be set for me.
source to share
As with Rust 1.18, there is no such thing. In fact, there is no even simpler option for disabling parallel testing.
Source
However, you might be helped cargo test -- --test-threads=1
, which is the recommended way to do what you are doing on the RUST_TEST_THREADS
envvar. Be aware that this only specifies the number of threads to use for testing in addition to the main thread.
source to share