}
}
+func TestNoCache(t *testing.T) {
+ switch runtime.GOOS {
+ case "windows":
+ t.Skipf("no unwritable directories on %s", runtime.GOOS)
+ }
+ if os.Getuid() == 0 {
+ t.Skip("skipping test because running as root")
+ }
+
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempFile("triv.go", `package main; func main() {}`)
+ tg.must(os.MkdirAll(tg.path("unwritable"), 0555))
+ tg.setenv("HOME", tg.path(filepath.Join("unwritable", "home")))
+ tg.unsetenv("GOCACHE")
+ tg.run("build", "-o", tg.path("triv"), tg.path("triv.go"))
+ tg.grepStderr("disabling cache", "did not disable cache")
+}
+
func TestTestVet(t *testing.T) {
tooSlow(t)
tg := testgo(t)
package cache
import (
- "cmd/go/internal/base"
+ "fmt"
"io/ioutil"
"os"
"path/filepath"
return
}
if err := os.MkdirAll(dir, 0777); err != nil {
- base.Fatalf("initializing cache in $GOCACHE: %s", err)
+ fmt.Fprintf(os.Stderr, "go: disabling cache (%s) due to initialization failure: %s\n", dir, err)
+ return
}
if _, err := os.Stat(filepath.Join(dir, "README")); err != nil {
// Best effort.
c, err := Open(dir)
if err != nil {
- base.Fatalf("initializing cache in $GOCACHE: %s", err)
+ fmt.Fprintf(os.Stderr, "go: disabling cache (%s) due to initialization failure: %s\n", dir, err)
+ return
}
defaultCache = c
}