Skip to content
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

x/tools/go/analysis/passes/loopclosure: handle t.Parallel #28771

Closed
alandonovan opened this issue Nov 13, 2018 · 2 comments
Closed

x/tools/go/analysis/passes/loopclosure: handle t.Parallel #28771

alandonovan opened this issue Nov 13, 2018 · 2 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@alandonovan
Copy link
Contributor

If a test calls t.Run in a loop, and the t.Run function literal contains a call to t.Parallel, then the t.Run effectively turns from a synchronous call into a go statement.

func Test(t *testing.T) {
    for name, value := range tests {
        t.Run(name, func(t *testing.T) {
            t.Parallel()
            ...
            use(value) // oops! read of value races with loop index variable update
        }
    }
}

The loopclosure check could recognize this case and treat such t.Run calls equivalent to a go statement.

@gopherbot gopherbot added this to the Unreleased milestone Nov 13, 2018
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@findleyr
Copy link
Contributor

Thanks for your feature request, @alandonovan. @adonovan and I have recently implemented this, in #55972.

@adonovan
Copy link
Member

Who says Severance is science fiction?

@golang golang locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants