fix: use copy of loop variable in parallel test (#23669)
This fixes an occurrence of a loop variable being captured in a parallel test. With the previous code, only the last test case is actually exercised. To work around this problem, we create a local copy of the range variable before the parallel test, as suggested in the Go documentation for the `testing` package: https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks Issue was found automatically using the `loopvarcapture` linter.pull/23674/head
parent
728070e115
commit
ee8ca451c4
|
@ -201,6 +201,7 @@ func TestScriptVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt // capture range variable
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
Loading…
Reference in New Issue