github.com/nuvolaris/goja@v0.0.0-20230825100449-967811910c6d/tc39_race_test.go (about) 1 //go:build race 2 // +build race 3 4 package goja 5 6 import ( 7 "testing" 8 ) 9 10 const ( 11 tc39MaxTestGroupSize = 8000 // to prevent race detector complaining about too many goroutines 12 ) 13 14 func (ctx *tc39TestCtx) runTest(name string, f func(t *testing.T)) { 15 ctx.testQueue = append(ctx.testQueue, tc39Test{name: name, f: f}) 16 if len(ctx.testQueue) >= tc39MaxTestGroupSize { 17 ctx.flush() 18 } 19 } 20 21 func (ctx *tc39TestCtx) flush() { 22 ctx.t.Run("tc39", func(t *testing.T) { 23 for _, tc := range ctx.testQueue { 24 tc := tc 25 t.Run(tc.name, func(t *testing.T) { 26 t.Parallel() 27 tc.f(t) 28 }) 29 } 30 }) 31 ctx.testQueue = ctx.testQueue[:0] 32 }