Skip to content

Commit 91d9766

Browse files
committed
internal/mod/zip: skip SizeLimit tests with -race
These tests create very large zip files on purpose, which is very slow under the race detector due to compress/flate. The tests and tested API have no concurrency at all, so the data race detector doesn't add anything useful. The slowness simply makes our CI's `go test -race ./...` too slow. Skip the tests when the data race detector is enabled. Since the upstream Go proposal for runtime/race.Enabled was rejected, add a similar constant to our internal/cuetest package. `go test -race ./internal/mod/zip` drops from ~40s to ~1s on my laptop. Note that we already skip these tests in `go test -short` mode, but we don't want CI to use `go test -race -short ./...`, as the data race detector is still useful on other non-short tests. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I44f707c8220af8bb943f5c3e162ef948a78a34c0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1170024 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
1 parent 665d19a commit 91d9766

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

internal/cuetest/norace.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2023 The CUE Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build !race
16+
17+
package cuetest
18+
19+
const RaceEnabled = false

internal/cuetest/race.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2023 The CUE Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build race
16+
17+
package cuetest
18+
19+
const RaceEnabled = true

internal/mod/zip/zip_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/google/go-cmp/cmp"
2222

23+
"cuelang.org/go/internal/cuetest"
2324
"cuelang.org/go/internal/mod/module"
2425
modzip "cuelang.org/go/internal/mod/zip"
2526
"golang.org/x/mod/sumdb/dirhash"
@@ -720,7 +721,7 @@ var sizeLimitTests = [...]sizeLimitTest{
720721
var sizeLimitVersion = module.MustNewVersion("example.com/large@v1", "v1.0.0")
721722

722723
func TestCreateSizeLimits(t *testing.T) {
723-
if testing.Short() {
724+
if testing.Short() || cuetest.RaceEnabled {
724725
t.Skip("creating large files takes time")
725726
}
726727
t.Parallel()
@@ -782,7 +783,7 @@ func TestCreateSizeLimits(t *testing.T) {
782783
}
783784

784785
func TestUnzipSizeLimits(t *testing.T) {
785-
if testing.Short() {
786+
if testing.Short() || cuetest.RaceEnabled {
786787
t.Skip("creating large files takes time")
787788
}
788789
t.Parallel()
@@ -849,7 +850,7 @@ func TestUnzipSizeLimits(t *testing.T) {
849850
}
850851

851852
func TestUnzipSizeLimitsSpecial(t *testing.T) {
852-
if testing.Short() {
853+
if testing.Short() || cuetest.RaceEnabled {
853854
t.Skip("skipping test; creating large files takes time")
854855
}
855856

0 commit comments

Comments
 (0)