Skip to content

Commit

Permalink
cmd/go: more informative test failures when GOROOT is stale
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
neild committed Nov 9, 2022
1 parent 7a92c4f commit cd8d1bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit cd8d1bc

Please sign in to comment.