Skip to content

Commit a13e64f

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/cache: fix crash in snapshot.Analyze with patch versions
Fix the same crash as golang/go#66195, this time in Analyze: don't set invalid Go versions on the types.Config. The largest part of this change was writing a realistic test, since the lack of a test for golang/go#66195 caused us to miss this additional location. It was possible to create a test that worked, by using a flag to select a go1.21 binary location. For this test, it was required to move a couple additional integration test preconditions into integration.Main (otherwise, the test would be skipped due to the modified environment). Fixes golang/go#66636 Change-Id: I24385474d4a6ebf6b7e9ae8f20948564bad3f55e Reviewed-on: https://go-review.googlesource.com/c/tools/+/576135 Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 2fe04db commit a13e64f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/testenv/testenv.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ var checkGoBuild struct {
4545
err error
4646
}
4747

48-
func hasTool(tool string) error {
48+
// HasTool reports an error if the required tool is not available in PATH.
49+
//
50+
// For certain tools, it checks that the tool executable is correct.
51+
func HasTool(tool string) error {
4952
if tool == "cgo" {
5053
enabled, err := cgoEnabled(false)
5154
if err != nil {
@@ -198,7 +201,7 @@ func allowMissingTool(tool string) bool {
198201
// NeedsTool skips t if the named tool is not present in the path.
199202
// As a special case, "cgo" means "go" is present and can compile cgo programs.
200203
func NeedsTool(t testing.TB, tool string) {
201-
err := hasTool(tool)
204+
err := HasTool(tool)
202205
if err == nil {
203206
return
204207
}

0 commit comments

Comments
 (0)