wire: fix test data race (google/go-cloud#168)

This was introduced in 7d83fb8532c1455d4e81b587f31d090320f5eb9f and is
surprisingly not caught by the race detector. I suspect that the testing
package makes it not a strict data race, but the result is still
undefined.
This commit is contained in:
Ross Light
2018-07-03 14:11:35 -07:00
parent 54cdfee544
commit 5e442802c0

View File

@@ -67,6 +67,7 @@ func TestWire(t *testing.T) {
t.Skip("go toolchain not available:", err) t.Skip("go toolchain not available:", err)
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
bctx := test.buildContext() bctx := test.buildContext()
@@ -137,6 +138,7 @@ func TestWire(t *testing.T) {
if test.wantError { if test.wantError {
continue continue
} }
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
bctx := test.buildContext() bctx := test.buildContext()