...
1env GO111MODULE=off
2
3# Integration test for cache directory calculation (cmd/go/internal/cache).
4
5[GOOS:windows] skip 'windows does not use XDG_CACHE_HOME'
6[GOOS:darwin] skip 'darwin does not use XDG_CACHE_HOME'
7[GOOS:ios] skip 'ios does not use XDG_CACHE_HOME'
8[GOOS:plan9] skip 'plan9 does not use XDG_CACHE_HOME'
9
10mkdir $WORK/gocache
11mkdir $WORK/xdg
12mkdir $WORK/home
13
14# Set GOCACHE, XDG_CACHE_HOME, and HOME.
15env GOCACHE=$WORK/gocache
16env XDG_CACHE_HOME=$WORK/xdg
17env HOME=$WORK/home
18
19# With all three set, we should prefer GOCACHE.
20go env GOCACHE
21stdout $WORK'/gocache$'
22
23# Without GOCACHE, we should prefer XDG_CACHE_HOME over HOME.
24env GOCACHE=
25go env GOCACHE
26stdout $WORK'/xdg/go-build$$'
27
28# With only HOME set, we should use $HOME/.cache.
29env XDG_CACHE_HOME=
30go env GOCACHE
31stdout $WORK'/home/.cache/go-build$'
32
33# With no guidance from the environment, we must disable the cache, but that
34# should not cause commands that do not write to the cache to fail.
35env HOME=
36go env GOCACHE
37stdout 'off'
View as plain text