From cd8d1bca2cc2ec228b21e5df893fec7a2e766e08 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 8 Nov 2022 17:02:49 -0800 Subject: [PATCH] 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 --- src/cmd/go/go_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) } } -- 2.50.0