-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: cmd/test: add flag to run tests in parallel by default #24335
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
Comments
Could you not accomplish the same with a comment, or a func that does nothing?
I believe that you could accomplish the same with a tool now - that is, a tool that would add I'm also worried that this would result in people using parallel tests a bit too agressively. For example, I've found that if one has to run thousands of subtests that are extremely cheap, marking each subtest as parallel actually hurts overall run-time slightly. I assume it's because of the extra goroutines and overhead. Don't get me wrong, I also think that tests should in general be parallel. I'm simply not sure that this is worthwhile doing in the current testing package. |
Yes, a comment is an option - but that is optional, once a programmer must put
That is also an option, but to my opinion it is not a good solution, and kind of workaround to the problem I am raising here.
Thanks! What do you mean current testing package? what is missing in the current testing package that we need to make this happen? |
In general, different tests can only run in parallel if they are designed to work that way. So the time to decide whether to run a test in parallel is when writing the test. At that point you can write |
The idea is that tests should be designed to run in parallel in the first place. Why not design them in that way?
If we were to write the test package from scratch, will this be the chosen solution for running tests in parallel? I think that this is not unequivocal...
On the other hand, running tests in parallel that find bugs in the tested program because they ran in parallel can save a lot of time. |
By all means design your tests to be parallel. But the Go project is not going to take the stance that all tests should be designed to be parallel.
That is the decision we have made, yes. |
Summary
Following #21214
Add to the
go test
command a flag--default-parallel
or similar, that would run all the tests in parallel - like the currentt.Parallel()
function behavior, until at.Serial()
ort.Serial(reason string)
functions where invoked.Details
When the new flag will be given, the test runner will invoke all the test functions and will skip the wait part before executing the next test function. Once a
t.Serial
function will be called in the test function, the go routing running the current test will be stopped and will be added to a serial tests queue. Once all the parallel test were done, test functions from the the serial queue will be invoked in a synchronous way.When the flag
--default-parallel
won't be given, thet.Serial
function will have no effect, and tests behavior will maintain it's current form.Backward Compatibility
As far as I can see, this is not a breaking change.
Reason
The reason why this change can contribute to the language are given in #21214:
The text was updated successfully, but these errors were encountered: