New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to opt out one test from parallel testing #33519

dns2utf8 opened this Issue May 9, 2016 · 3 comments


None yet
5 participants
Copy link

dns2utf8 commented May 9, 2016

Hi all

I had a problem while testing the threadpool-crate because all test run in parallel and all of them use the whole cpu.
Would it be possible to add a additional flag for test like this? Maybe something like this:

fn test_heavy_load_on_cpu_or_gpu_or_global_state() {
  // working hard here ...

The implementation would have to queue these test and run them sequencally.

The flag no_parallel seems very expressiv, but I prefere a positive keyword like single, serial or individual or something like this.

What do you think?


This comment has been minimized.

Copy link

arthurprs commented Aug 24, 2016

I think we really need something like this. Like proposed here or some sort of cargo.toml setting.

It's almost always possible to make tests parallel safe but we're making all rust users suffer from that paper-cut over and over again, let's do it once (in core) and save tons of dev hours.

jwilm added a commit to racer-rust/racer that referenced this issue Dec 23, 2016

Remove test_fixtures dependency
This was preventing us from publishing to

The test_fixtures directory was moved into a test project. The tests
that use those fixtures now change directory during the test. This is a
problem for other tests which expect to be in the normal directory or at
least not change mid test. To deal with that, and to prevent developers
from needing to run tests with RUST_TEST_THREADS=1, each test takes a
shared lock to synchronize them. In an ideal world, the test threads
flag would just be an option in Cargo.toml, or something like
rust-lang/rust#33519 would exist.

This comment has been minimized.

Copy link

doxxx commented Apr 3, 2017

Here's a use-case which may provide some additional context:

I have a number of modules that work with files. Each test uses fs::DirBuilder::new().recursive(true).create(&dir).unwrap(); to create a directory in which the test files will be created and then fs::remove_dir_all(dir).unwrap(); at the end to clean it up. Each test uses a different path, target/debug/tmp/test/<module>/<test>, but they all share a common prefix.

If one of the shared parent directories does not exist when the tests are run, the recursive directory creation in each of the parallel tests races to create the parent directories. This race sometimes results in one of the tests failing with a panic because the mkdir returns an Err indicating that the directory already exists.

I think my only solution is to use a global mutex around the directory creation.


This comment has been minimized.

Copy link

nrc commented Jul 10, 2017

There is a work around for this using a Mutex, we would therefore not add this to the current test framework. See #42684 (comment) for a little more discussion.

@nrc nrc closed this Jul 10, 2017

@stjepang stjepang referenced this issue Sep 23, 2017


Add tests #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment