]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/go,misc/ios: fix tests on iOS
authorElias Naur <mail@eliasnaur.com>
Sun, 17 Mar 2019 15:07:25 +0000 (16:07 +0100)
committerElias Naur <mail@eliasnaur.com>
Sun, 17 Mar 2019 17:00:42 +0000 (17:00 +0000)
Now that modules are always on, cmd/go tests require a valid
GOCACHE. However, on iOS where the go tool is not available, the
cmd/go test driver ends up setting GOCACHE to the empty string.
Fix it by falling back to the builtin default cache directory.

The iOS exec wrapper passes the environment variables to the app
on the device, including $HOME used for the default cache directory.
Skip $HOME to let the device specific and writable $HOME be used
instead.

Should fix cmd/go on the iOS builders that broke when GO111MODULE
defaulted to on.

Change-Id: I0939f5b8aaa1d2db95e64c99f4130eee2d0b4d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/167938
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/ios/go_darwin_arm_exec.go
src/cmd/go/go_test.go

index 6a3d9def68208d3fd07e4e0dfd483f8c8e4f8e56..8912d1e8fc6e2262129ab5aa7a33e65dd4d749ef 100644 (file)
@@ -467,8 +467,8 @@ func idevCmd(cmd *exec.Cmd) *exec.Cmd {
 func run(appdir, bundleID string, args []string) error {
        var env []string
        for _, e := range os.Environ() {
-               // Don't override TMPDIR on the device.
-               if strings.HasPrefix(e, "TMPDIR=") {
+               // Don't override TMPDIR, HOME on the device.
+               if strings.HasPrefix(e, "TMPDIR=") || strings.HasPrefix(e, "HOME=") {
                        continue
                }
                env = append(env, e)
index 60e02e75324cd98507e5ce8052518e6b91740b4e..faf953ddebd71b23a5e921c37dea036234fea858 100644 (file)
@@ -6,6 +6,7 @@ package main_test
 
 import (
        "bytes"
+       "cmd/go/internal/cache"
        "cmd/internal/sys"
        "context"
        "debug/elf"
@@ -166,6 +167,7 @@ func TestMain(m *testing.M) {
                defer removeAll(testTmpDir)
        }
 
+       testGOCACHE = cache.DefaultDir()
        if canRun {
                testBin = filepath.Join(testTmpDir, "testbin")
                if err := os.Mkdir(testBin, 0777); err != nil {