Skip to content

Commit f84f9e5

Browse files
authored
Merge pull request #60 from cockroachdb/fix-10s-race
fix 10s logging data race
2 parents 217001b + 0b21448 commit f84f9e5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

datadriven.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ func runDirective(t testing.TB, r *testDataReader, f func(testing.TB, *TestData)
347347
// Set up a goroutine to log periodically if the function is taking a long
348348
// time. This is useful to pinpoint the cause of a test timeout.
349349
done := make(chan struct{})
350-
defer close(done)
351350
go func() {
352351
startTime := time.Now()
353352
for {
@@ -359,6 +358,11 @@ func runDirective(t testing.TB, r *testDataReader, f func(testing.TB, *TestData)
359358
}
360359
}
361360
}()
361+
defer func() {
362+
// Because the channel is unbuffered, we wait here until the goroutine is
363+
// exiting.
364+
done <- struct{}{}
365+
}()
362366

363367
actual := f(t, d)
364368
fReturned = true

0 commit comments

Comments
 (0)