Skip to content

Commit cc4274c

Browse files
committed
extract go versions into bash script and allow compile test on specific versions
1 parent 89e5ed2 commit cc4274c

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

etc/run-compile-check-test.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
set -eu
55
set +x
66

7-
echo "Running internal/test/compilecheck"
7+
# Use specified GO_VERSIONS or default to all supported versions.
8+
# To run the compile check tests with specific Go versions, set the GO_VERSIONS environment variable before running this script.
9+
# For example, to use a single version: GO_VERSIONS=1.25 ./etc/run-compile-check-test.sh
10+
# Or to use multiple versions: GO_VERSIONS="1.23,1.24,1.25" ./etc/run-compile-check-test.sh
11+
if [ -z "${GO_VERSIONS:-}" ]; then
12+
GO_VERSIONS="1.19,1.20,1.21,1.22,1.23,1.24,1.25"
13+
fi
14+
export GO_VERSIONS
15+
16+
echo "Running internal/test/compilecheck with Go versions: $GO_VERSIONS"
817
pushd internal/test/compilecheck
918
GOWORK=off go test -timeout 30m -v ./... >>../../../test.suite
1019
popd

internal/test/compilecheck/compile_check_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ import (
1212
"io"
1313
"os"
1414
"path/filepath"
15+
"strings"
1516
"testing"
1617

1718
"github.com/stretchr/testify/assert"
1819
"github.com/stretchr/testify/require"
1920
"github.com/testcontainers/testcontainers-go"
2021
)
2122

22-
var versions = []string{
23-
"1.19",
24-
"1.20",
25-
"1.21",
26-
"1.22",
27-
"1.23",
28-
"1.24",
29-
"1.25",
23+
func getVersions(t *testing.T) []string {
24+
t.Helper()
25+
26+
env := os.Getenv("GO_VERSIONS")
27+
if env == "" {
28+
t.Skip("GO_VERSIONS environment variable not set")
29+
}
30+
31+
return strings.Split(env, ",")
3032
}
3133

3234
func TestCompileCheck(t *testing.T) {
35+
versions := getVersions(t)
3336
cwd, err := os.Getwd()
3437
require.NoError(t, err)
3538

0 commit comments

Comments
 (0)