aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-10-29 22:32:59 -0400
committerIan Lance Taylor <iant@golang.org>2016-10-30 03:14:12 +0000
commit753caecc7e576e46a329b71c49dbf0ea9bfbd867 (patch)
treec7e368fd06c13c5371e9558f3e6a40c44e937897 /src
parent7db996ee77b20b68ee583c65d59be1d81cef9090 (diff)
downloadgo-753caecc7e576e46a329b71c49dbf0ea9bfbd867.tar.xz
cmd/go: set CCACHE_DIR when setting HOME to non-existent dir
This fixes systems for which ccache is the default compiler. Also remove a couple of temporary files created by TestImportMain. Fixes #17668. Change-Id: I1edefdcec5f417be0533c146253c35ff4928c1c0 Reviewed-on: https://go-review.googlesource.com/32328 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/go_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 86c8a80cef..93639ee5ea 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -99,6 +99,12 @@ func TestMain(m *testing.M) {
// Don't let these environment variables confuse the test.
os.Unsetenv("GOBIN")
os.Unsetenv("GOPATH")
+ if home, ccacheDir := os.Getenv("HOME"), os.Getenv("CCACHE_DIR"); home != "" && ccacheDir == "" {
+ // On some systems the default C compiler is ccache.
+ // Setting HOME to a non-existent directory will break
+ // those systems. Set CCACHE_DIR to cope. Issue 17668.
+ os.Setenv("CCACHE_DIR", filepath.Join(home, ".ccache"))
+ }
os.Setenv("HOME", "/test-go-home-does-not-exist")
r := m.Run()
@@ -2536,6 +2542,7 @@ func TestImportMain(t *testing.T) {
var _ = xmain.X
func TestFoo(t *testing.T) {}
`)
+ tg.creatingTemp("p4" + exeSuffix)
tg.run("build", "p4")
tg.runFail("test", "p4")
tg.grepStderr("import \"x\" is a program, not an importable package", "did not diagnose package main")
@@ -2550,6 +2557,7 @@ func TestImportMain(t *testing.T) {
var _ = xmain.X
func TestFoo(t *testing.T) {}
`)
+ tg.creatingTemp("p5" + exeSuffix)
tg.run("build", "p5")
tg.runFail("test", "p5")
tg.grepStderr("import \"x\" is a program, not an importable package", "did not diagnose package main")