Skip to content

Commit cbdd996

Browse files
committed
internal/ci: set GORACE=atexit_sleep_ms=10 for go test -race
On my laptop, lowering this default makes `go test -race -count=1 ./...` drop from around 1m41s to 1m35s, since we have many packages with tests. We also need testscript to propagate this env var, as otherwise any executions of cue via the test binary will not see any GORACE env var and will sleep for one second as well. With the two changes, `go test -race` in ./cmd/cue/cmd drops from 25s to 5s on my laptop. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Id015563ae6fbc510dac22197c9be52756bcf81b7 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1169882 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
1 parent 6923617 commit cbdd996

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

.github/workflows/trybot.yml

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180
- if: (matrix.go-version == '1.21.x' && matrix.runner == 'ubuntu-22.04')
181181
name: Test with -race
182182
run: go test -race ./...
183+
env:
184+
GORACE: atexit_sleep_ms=10
183185
- if: (matrix.go-version == '1.21.x' && matrix.runner == 'ubuntu-22.04')
184186
name: Check
185187
run: go vet ./...

cmd/cue/cmd/script_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func TestScript(t *testing.T) {
106106
"GOPROXY="+srv.URL,
107107
"GONOSUMDB=*", // GOPROXY is a private proxy
108108
homeEnvName()+"="+home,
109+
"GORACE="+os.Getenv("GORACE"), // TODO(mvdan): testscript should do this by default
109110
)
110111
return nil
111112
},

internal/ci/github/trybot.cue

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ workflows: trybot: _repo.bashWorkflow & {
128128

129129
_goTestRace: json.#step & {
130130
name: "Test with -race"
131+
env: GORACE: "atexit_sleep_ms=10" // Otherwise every Go package being tested sleeps for 1s; see https://go.dev/issues/20364.
131132
run: "go test -race ./..."
132133
}
133134
}

0 commit comments

Comments
 (0)