From f9197a7043e48b6d2caa5ea1b0a969495f998d48 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 17 Mar 2020 10:22:39 -0400 Subject: run.{bash,bat,rc}: use ../bin/go instead of the go binary in $PATH https://golang.org/doc/contribute.html#quick_test currently suggests running 'make.bash' and 'run.bash' separately, but 'run.bash' potentially uses a 'go' command resolved from the wrong GOROOT, which in turn sets the wrong GOROOT for further commands. Updates #32674 Updates #17896 Change-Id: I4925d478d0fc7351c4f6d40830ab17d4d688348d Reviewed-on: https://go-review.googlesource.com/c/go/+/223741 Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot Reviewed-by: Dmitri Shuralyov Reviewed-by: Katie Hockman --- src/run.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/run.bash') diff --git a/src/run.bash b/src/run.bash index e18540c990..706b4b60ee 100755 --- a/src/run.bash +++ b/src/run.bash @@ -16,8 +16,13 @@ set -e -eval $(go env) -export GOROOT # the api test requires GOROOT to be set. +if [ ! -f ../bin/go ]; then + echo 'run.bash must be run from $GOROOT/src after installing cmd/go' 1>&2 + exit 1 +fi + +eval $(../bin/go env) +export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go. # We disallow local import for non-local packages, if $GOROOT happens # to be under $GOPATH, then some tests below will fail. $GOPATH needs @@ -56,4 +61,4 @@ if ulimit -T &> /dev/null; then [ "$(ulimit -H -T)" = "unlimited" ] || ulimit -S -T $(ulimit -H -T) fi -exec go tool dist test -rebuild "$@" +exec ../bin/go tool dist test -rebuild "$@" -- cgit v1.3-5-g45d5