I have tests which share a common resource and can't be executed concurrently. These tests fail with cargo test
, but work with RUST_TEST_THREADS=1 cargo test
.
I can modify the tests to wait on a global mutex, but I don't want to clutter them if there is any simpler way to force cargo
set this environment variable for me.
Target Selection. When no target selection options are given, cargo test will build the following targets of the selected packages: lib — used to link with binaries, examples, integration tests, and doc tests. bins (only if integration tests are built and required features are available)
The default behavior of the binary produced by cargo test is to run all the tests in parallel and capture output generated during test runs, preventing the output from being displayed and making it easier to read the output related to the test results.
Cargo can run your tests with the cargo test command. Cargo looks for tests to run in two places: in each of your src files and any tests in tests/ . Tests in your src files should be unit tests and documentation tests. Tests in tests/ should be integration-style tests.
By default, cargo bench uses the bench profile, which enables optimizations and disables debugging information. If you need to debug a benchmark, you can use the --profile=dev command-line option to switch to the dev profile. You can then run the debug-enabled benchmark within a debugger.
As of Rust 1.18, there is no such thing. In fact, there is not even a simpler option to disable parallel testing.
Source
However, what might help you is cargo test -- --test-threads=1
, which is the recommended way of doing what you are doing over the RUST_TEST_THREADS
envvar. Keep in mind that this only sets the number of threads used for testing in addition to the main thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With