-
-
Notifications
You must be signed in to change notification settings - Fork 15k
cargo test 'test-threads' uses more threads than specified #88235
Copy link
Copy link
Closed as not planned
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryA-threadArea: `std::thread`Area: `std::thread`C-bugCategory: This is a bug.Category: This is a bug.T-testing-devexRelevant to the testing devex team (testing DX), which will review and decide on the PR/issue.Relevant to the testing devex team (testing DX), which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryA-threadArea: `std::thread`Area: `std::thread`C-bugCategory: This is a bug.Category: This is a bug.T-testing-devexRelevant to the testing devex team (testing DX), which will review and decide on the PR/issue.Relevant to the testing devex team (testing DX), which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Done
Summary
So I have noticed that
cargo testactually uses more threads than is actually specified, and actually spawns a new thread for every test, as opposed to re-using threads in a pool. This is in many ways a bug because some tests the depend on thread local storage cannot be run in concurrent mode.Reproduction Steps
tlocal.rs, and list it in thelib.rsas a module.cargo test -- --test-threads=2I expected to see this happen: The tests pass.
Instead, this happened: The test fail with these errors:
Meta
rustc --version --verbose:Problem
This is a bug because more than the stated number of threads are actually being used to run the tests. Ideally, this should either be clarified in the docs, or a way of running tests in a thread pool should be provided.