8000 proposal: testing: run tests in parallel by default · Issue #73805 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

proposal: testing: run tests in parallel by default #73805

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

Open
CAFxX opened this issue May 21, 2025 · 2 comments
Open

proposal: testing: run tests in parallel by default #73805

CAFxX opened this issue May 21, 2025 · 2 comments
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Performance Proposal
Milestone

Comments

@CAFxX
Copy link
Contributor
CAFxX commented May 21, 2025

Proposal Details

#21214 proposed the same but was declined -- mostly because at the time we had no good way of rolling out such a change safely. As this is not the case anymore, and the benefits keep increasing with time (core counts are increasing, codebases and test suites are growing, etc.), I think it would be worth reconsidering it.

The idea would be to make parallel execution the default for modules that specify a go version (not toolchain version) higher than v1.X. Modules with go version below v1.X would still default to serial execution, as today. This would mean that behaviour would not change until a module go version (not toolchain version) is manually updated to v1.X or later.

Individual tests would be given a way to opt-out of parallel execution, similar to how today we allow individual tests to opt-in to parallel execution.

I encourage reviewers to focus on the goal when discussing this proposal, i.e. I welcome alternative ways/solutions to achieve the same goal, and will gladly update the proposal if a better solution is suggested. Some discussion is happening in https://gophers.slack.com/archives/C0VP8EF3R/p1747791714490489.

Proposal

  • Add testing.T.Serial() to allow individual tests to opt out of the new default. Mention that Serial was the default before go v1.X. No-op if the default is serial execution. Panics or fails the test if called after Parallel().
  • Update the doc for testing.T.Parallel() to mention that this is the default starting with go v1.X. No-op if the default is parallel execution. Panics or fails the test if called after Serial().
  • For modules that specify in go.mod a go version equal or greater than v1.X, run the tests in parallel by default; modules that specify an older version would still run tests serially be default.
  • Linters and other tools could start flagging t.Parallel() calls as unneeded for modules with a go.mod go version equal or greater than v1.X. Migration assistance tools can be built (possibly even in go fix) that would add Serial() calls to any test that does not have a Parallel() call, and remove Parallel() calls from any test that has it.
@CAFxX CAFxX added the Proposal label May 21, 2025
@gopherbot gopherbot added this to the Proposal milestone May 21, 2025
@gabyhelp gabyhelp added the LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool label May 21, 2025
@seankhliao seankhliao changed the title proposal: testing: run tests in parallel by default (take 2) proposal: testing: run tests in parallel by default May 21, 2025
@dolmen
Copy link
Contributor
dolmen commented May 23, 2025

Compatible test suites can already opt-in by injecting t.Parallel() progressively in all tests. But I guess that many test suites are not prepared for that to be applied all at once for all tests.

When a module upgrades the Go version, that's usually to use new features of a newer Go, such as new features of the stdlib. Nobody wants to be forced to rewrite his testsuite for parallel testing compliance as well just because of go mod edit -go=....

So I'm against this proposal.

However, as someone who also has already attempted to upgrade a testsuite to massively use parallel testing in top level tests (running with go test -parallel=50 -race), I think that a go test flag that would change the default would be helpful to quickly evaluate the effort needed without having to edit all tests to add t.Parallel() everywhere: -parallelforce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Performance Proposal
Projects
None yet
Development

No branches or pull requests

5 participants
0