Skip to content

Commit 2a0d7e2

Browse files
Sean Christophersonianlancetaylor
Sean Christopherson
authored andcommitted
run.bash: set GOPATH to $GOROOT/nil before running tests
Set $GOPATH to a semantically valid, non-empty string that cannot conflict with $GOROOT to avoid false test failures that occur when $GOROOT resides under $GOPATH. Unsetting GOPATH is no longer viable as Go now defines a default $GOPATH that may conflict with $GOROOT. Fixes #19237 Change-Id: I376a2ad3b18e9c4098211b988dde7e76bc4725d2 Reviewed-on: https://go-review.googlesource.com/37396 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 1564817 commit 2a0d7e2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/run.bash

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ set -e
88
eval $(go env)
99
export GOROOT # the api test requires GOROOT to be set.
1010

11+
# We disallow local import for non-local packages, if $GOROOT happens
12+
# to be under $GOPATH, then some tests below will fail. $GOPATH needs
13+
# to be set to a non-empty string, else Go will set a default value
14+
# that may also conflict with $GOROOT. The $GOPATH value doesn't need
15+
# to point to an actual directory, it just needs to pass the semantic
16+
# checks performed by Go. Use $GOROOT to define $GOPATH so that we
17+
# don't blunder into a user-defined symbolic link.
18+
GOPATH=$GOROOT/nonexistentpath
19+
export GOPATH
20+
1121
unset CDPATH # in case user has it set
12-
unset GOPATH # we disallow local import for non-local packages, if $GOROOT happens
13-
# to be under $GOPATH, then some tests below will fail
1422
unset GOBIN # Issue 14340
1523

1624
export GOHOSTOS

0 commit comments

Comments
 (0)