]> Cypherpunks repositories - gostls13.git/commitdiff
all: replace os.Getenv("GO_BUILDER_NAME") with testenv.Builder in tests
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 11 Sep 2025 23:48:04 +0000 (23:48 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 15 Sep 2025 21:21:33 +0000 (14:21 -0700)
Some tests still reach for GO_BUILDER_NAME directly. This change makes
it so that they go through testenv.Builder.

There are a couple more, but changing them may also cause tests to start
failing. Done in a follow-up.

Change-Id: Id2453b7b62f5ebf3594e92fa53724a577a97440f
Reviewed-on: https://go-review.googlesource.com/c/go/+/703135
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/cgo/internal/testcarchive/carchive_test.go
src/cmd/cgo/internal/testcshared/cshared_test.go
src/cmd/cgo/internal/testplugin/plugin_test.go
src/cmd/cgo/internal/testshared/shared_test.go
src/cmd/link/link_test.go
src/syscall/getdirentries_test.go

index 155eca9a73bdb2b38f7bd3e7b03d74c5453c1033..c0ad79f23144a7d89ce45356de77e8cdba17ebcf 100644 (file)
@@ -58,7 +58,7 @@ func TestMain(m *testing.M) {
 }
 
 func testMain(m *testing.M) int {
-       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if testing.Short() && testenv.Builder() == "" {
                globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
                return m.Run()
        }
index 096959562c02f2e27449a1aeecda6d030b13b4af..2c4d33f599f8d7fa1681a484c7b7afe9699932d1 100644 (file)
@@ -44,7 +44,7 @@ func TestMain(m *testing.M) {
 func testMain(m *testing.M) int {
        log.SetFlags(log.Lshortfile)
        flag.Parse()
-       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if testing.Short() && testenv.Builder() == "" {
                globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
                return m.Run()
        }
index 5bff81092cad8274684c555f2624b6f1a09896b0..2afb542ec4f17c43ace6529613ce737bbd758b7a 100644 (file)
@@ -46,7 +46,7 @@ func prettyPrintf(format string, args ...interface{}) {
 }
 
 func testMain(m *testing.M) int {
-       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if testing.Short() && testenv.Builder() == "" {
                globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
                return m.Run()
        }
index e92746037614823761ba4be11425481d5a0de01b..3d401b604ebbba85d40ebe3be16d5a985f369553 100644 (file)
@@ -96,7 +96,7 @@ func goCmd(t *testing.T, args ...string) string {
 
 // TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit).
 func testMain(m *testing.M) (int, error) {
-       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if testing.Short() && testenv.Builder() == "" {
                globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
                return m.Run(), nil
        }
@@ -554,7 +554,7 @@ func checkPIE(t *testing.T, name string) {
 }
 
 func TestTrivialPIE(t *testing.T) {
-       if strings.HasSuffix(os.Getenv("GO_BUILDER_NAME"), "-alpine") {
+       if strings.Contains(testenv.Builder(), "-alpine") {
                t.Skip("skipping on alpine until issue #54354 resolved")
        }
        globalSkip(t)
index a87d452ed39446c461beec7690d1a1224e8db734..0125ba8e0f56beaa678890426e0929bda12b34c2 100644 (file)
@@ -280,7 +280,7 @@ func TestBuildForTvOS(t *testing.T) {
        if runtime.GOOS != "darwin" {
                t.Skip("skipping on non-darwin platform")
        }
-       if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if testing.Short() && testenv.Builder() == "" {
                t.Skip("skipping in -short mode with $GO_BUILDER_NAME empty")
        }
        if err := testenv.Command(t, "xcrun", "--help").Run(); err != nil {
index b5361ddaef702473905abb57d93368af41265138..f879e2a5390c61bc9975a0224c2cb85cb51a965c 100644 (file)
@@ -8,6 +8,7 @@ package syscall_test
 
 import (
        "fmt"
+       "internal/testenv"
        "os"
        "path/filepath"
        "slices"
@@ -24,7 +25,7 @@ func TestGetdirentries(t *testing.T) {
        }
 }
 func testGetdirentries(t *testing.T, count int) {
-       if count > 100 && testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
+       if count > 100 && testing.Short() && testenv.Builder() == "" {
                t.Skip("skipping in -short mode")
        }
        d := t.TempDir()