1 env GO111MODULE=off
2
3 # As of Go 1.12, the module cache is required.
4
5 # If none of the variables we use to locate GOCACHE are set, the cache is off
6 # and we cannot build.
7 env GOCACHE=
8 env XDG_CACHE_HOME=
9 env HOME=
10 [plan9] env home=
11 [windows] env LocalAppData=
12 ! go build -o triv triv.go
13 stderr 'build cache is required, but could not be located: GOCACHE is not defined and .*'
14
15 # If GOCACHE is set but is not an absolute path, and we cannot build.
16 env GOCACHE=test
17 ! go build -o triv triv.go
18 stderr 'build cache is required, but could not be located: GOCACHE is not an absolute path'
19
20 # An explicit GOCACHE=off also disables builds.
21 env GOCACHE=off
22 ! go build -o triv triv.go
23 stderr 'build cache is disabled by GOCACHE=off'
24
25 # If GOCACHE is set to an unwritable directory, we should diagnose it as such.
26 [windows] stop # Does not support unwritable directories.
27 [root] skip # Can write to unwritable directories.
28
29 mkdir $WORK/unwritable/home
30 chmod 0555 $WORK/unwritable/home
31 [!plan9] env HOME=$WORK/unwritable/home
32 [plan9] env home=$WORK/unwritable/home
33
34 env GOCACHE=$WORK/unwritable/home
35 ! go build -o triv triv.go
36 stderr 'failed to initialize build cache.* permission denied'
37
38 -- triv.go --
39 package main
40 func main() {}
41
View as plain text