File: tc39_race_test.go

package info (click to toggle)
golang-github-dop251-goja 0.0~git20250630.0.58d95d8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,264 kB
  • sloc: javascript: 454; perl: 184; makefile: 6; sh: 1
file content (32 lines) | stat: -rw-r--r-- 622 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//go:build race
// +build race

package goja

import (
	"testing"
)

const (
	tc39MaxTestGroupSize = 8000 // to prevent race detector complaining about too many goroutines
)

func (ctx *tc39TestCtx) runTest(name string, f func(t *testing.T)) {
	ctx.testQueue = append(ctx.testQueue, tc39Test{name: name, f: f})
	if len(ctx.testQueue) >= tc39MaxTestGroupSize {
		ctx.flush()
	}
}

func (ctx *tc39TestCtx) flush() {
	ctx.t.Run("tc39", func(t *testing.T) {
		for _, tc := range ctx.testQueue {
			tc := tc
			t.Run(tc.name, func(t *testing.T) {
				t.Parallel()
				tc.f(t)
			})
		}
	})
	ctx.testQueue = ctx.testQueue[:0]
}