-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
"jobs" CLI flag possibly not taking effect #1591
Comments
Thanks for the report! Currently the |
Thanks for the reply! When you say "currently" do you mean the intent is for that flag to eventually do what I expected it to do? If so, I might look into a PR for that. If not, there is probably a documentation change I could make to make it clearer that the flag doesn't affect the test run itself. |
Ah no sorry I didn't mean that we intended it to do so. Perhaps the |
After talking to both @wycats and @alexcrichton about whether or not Cargo should behave as I originally expected it would, I'd like to nominate this issue for reopen and more discussion. I think one of the following things should happen:
|
I just spent an hour beging confused about this too. 👍 on the change @jimmycuadra proposes. |
Hm ok, I'll reopen for discussion, but I'd like to explain a few more things that I was thinking as well:
I agree, but I also want Cargo to support multiple testing frameworks one day, and I want Cargo to continue to do what I expect it to do at that point. If Cargo only passes down parallelism via an environment variable then we're requiring that all testing frameworks respect this environment variable, which may not always be desired. I do not personally expect cargo do be anything beyond a wrapper around
I agree! |
One possible compromise would be making the docs change so that it's clear --jobs doesn't affect the thread count for the test run, and opening an issue on Rust itself to get a --test-threads flag added to replace the environment variable. I'm still not sure how best to balance the desire for Cargo to be agnostic to the test framework with an intuitive user experience for people just starting with Rust/Cargo. |
My preferred route for now is to use this issue to track adding documentation to |
Addresses #1591. I believe this issue only affects `cargo bench` and `cargo test`. If it's applicable to any of the other commands, let me know and I'll amend this.
#1639 was merged, so I'm closing this. |
Hello! I'm trying to run the test suite for one of my Rust programs with only a single thread, because each test changes state in an external database and needs to clean up after itself before the next test starts. (This clean up is implemented via the Drop trait on a struct being created in each test.)
However, each of my tests fails intermittently, even when running
cargo test -j1
. I put print statements in the constructor andDrop::drop
to see if each struct was being dropped before the next one was being created. What I discovered was that test runs frequently printed multiple constructor calls before their corresponding drops. Perhaps I'm misunderstanding what's actually happening, but this seems to suggest that test cases are actually running in parallel even though I specified that only one job should be used.Here is a small program that demonstrates the issue:
Example output:
As you can see, a second call to "new" is being made before the previous one has called "drop."
Am I using the --jobs flag incorrectly? Am I misunderstanding what it actually does? How can I get my test cases to run sequentially? Thanks!
The text was updated successfully, but these errors were encountered: