You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@moricho I managed to find the culprit, here's a reproducer:
func TestParallel(t *testing.T) {
t.Parallel()
cases := map[string]struct {
a string
b string
}{
"a": {
"a", "b",
},
"b": {
"a", "b",
},
}
wg := sync.WaitGroup{}
for name, c := range cases {
c := c
wg.Add(1)
go t.Run(name, func(t *testing.T) {
defer wg.Done()
require.Equal(t, "a", c.a)
require.Equal(t, "b", c.b)
})
}
wg.Wait()
}
Basically this is a test I have that require to run all its subtests in parallel.
We can't rely on t.Parallel() because the default number of parallel tests depends on the number of CPU cores
Here we want all subtests to be run in parallel to trigger the behavior we want to test
for name, c := range cases {
name := name
c := c
wg.Add(1)
go func() {
t.Run(name, func(t *testing.T) {
defer wg.Done()
require.Equal(t, "a", c.a)
require.Equal(t, "b", c.b)
})
}()
}
Some projects trigger this
tparallel
crash. I can't share the source code that triggers this crash however.The text was updated successfully, but these errors were encountered: