From: Damien Neil Date: Wed, 9 Nov 2022 01:02:49 +0000 (-0800) Subject: cmd/go: more informative test failures when GOROOT is stale X-Git-Tag: go1.20rc1~357 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cd8d1bca2cc2ec228b21e5df893fec7a2e766e08;p=gostls13.git cmd/go: more informative test failures when GOROOT is stale If GOROOT is stale, test fail when commands unexpectedly write to GOROOT. Include an message in the test failure indicating that this is a possible and expected reason for the failure, and how to fix it. For #48698. Change-Id: I057c20260bab09aebf684e8f20794ab8fc0ede1e Reviewed-on: https://go-review.googlesource.com/c/go/+/448895 TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Run-TryBot: Damien Neil --- diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 4f451e614b..eebc3266c8 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -129,7 +129,8 @@ func TestMain(m *testing.M) { } callerPos = fmt.Sprintf("%s:%d: ", file, line) } - return fmt.Errorf("%stestgo must not write to GOROOT (installing to %s)", callerPos, filepath.Join("GOROOT", rel)) + notice := "This error error can occur if GOROOT is stale, in which case rerunning make.bash will fix it." + return fmt.Errorf("%stestgo must not write to GOROOT (installing to %s) (%v)", callerPos, filepath.Join("GOROOT", rel), notice) } }