-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Comments
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. |
This was preventing us from publishing to crates.io. 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.
Here's a use-case which may provide some additional context: I have a number of modules that work with files. Each test uses 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 I think my only solution is to use a global mutex around the directory creation. |
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. |
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:
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 likesingle
,serial
orindividual
or something like this.What do you think?
Regards
The text was updated successfully, but these errors were encountered: