]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: more informative test failures when GOROOT is stale
authorDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 01:02:49 +0000 (17:02 -0800)
committerDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 17:39:55 +0000 (17:39 +0000)
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 <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>

src/cmd/go/go_test.go

index 4f451e614b707d2b91e1a51b262bb3b56a25eb9c..eebc3266c89cc816077fc13e3c344bba0d92b775 100644 (file)
@@ -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)
                        }
                }