Skip to content

x/tools/gopls/test/debug: test fails when run in the module cache #59841

Closed
@bcmills

Description

@bcmills

What version of Go are you using (go version)?

(Built from CL 489076 patchset 2.)

$ go version
go version devel go1.21-0e5f77a24c Fri Apr 21 14:45:51 2023 -0400 linux/amd64

Does this issue reproduce with the latest release?

Yes, but it's harder to reproduce due to #56222.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/bcmills/.cache/go-build"
GOENV="/usr/local/google/home/bcmills/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/tmp/tmp.hIhiXWubgo/.gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/tmp.hIhiXWubgo/.gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/bcmills/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/bcmills/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.21-0e5f77a24c Fri Apr 21 14:45:51 2023 -0400"
GCCGO="/usr/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/tmp/tmp.hIhiXWubgo/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2658695689=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go mod init example
go: creating new go.mod: module example

$ go get -t golang.org/x/tools/gopls/test/debug@master golang.org/x/tools@master
go: added golang.org/x/tools v0.8.1-0.20230425201836-76e1037d71f8
go: added golang.org/x/tools/gopls v0.0.0-20230425201836-76e1037d71f8

$ go test golang.org/x/tools/gopls/test/debug

What did you expect to see?

The test should either pass or be skipped.

What did you see instead?

The test fails: it assumes that the golang.org/x/tools module is located up from the gopls module, but that assumption does not hold in the module cache. (Instead, the two modules are downloaded independently and stored in disjoint subtrees.)

$ go test golang.org/x/tools/gopls/test/debug
--- FAIL: TestTemplates (2.32s)
    debug_test.go:61: compiler error, e.g. /tmp/tmp.hIhiXWubgo/.gopath/pkg/mod/golang.org/x/tools/gopls@v0.0.0-20230425201836-76e1037d71f8/internal/lsp/debug/metrics.go:8:2: could not import golang.org/x/tools/internal/event/export/metric (invalid package name: "")
FAIL
FAIL    golang.org/x/tools/gopls/test/debug     2.377s
FAIL

Activity

added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Apr 26, 2023
added this to the Unreleased milestone on Apr 26, 2023
added
TestingAn issue that has been verified to require only test changes, not just a test failure.
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Apr 26, 2023
gopherbot

gopherbot commented on Apr 26, 2023

@gopherbot
Contributor

Change https://go.dev/cl/489216 mentions this issue: test/debug: load packages from outside the gopls module

gopherbot

gopherbot commented on Apr 26, 2023

@gopherbot
Contributor

Change https://go.dev/cl/489215 mentions this issue: internal/gocommand: simplify GoVersion invocation

gopherbot

gopherbot commented on Apr 26, 2023

@gopherbot
Contributor

Change https://go.dev/cl/489235 mentions this issue: internal/lsp/safetoken: load packages in TestGoplsSourceDoesNotCallTokenFileMethods from outside the gopls module

added a commit that references this issue on Feb 16, 2024
2415ce1
locked and limited conversation to collaborators on May 1, 2024
added a commit that references this issue on Jan 11, 2025
33689ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.TestingAn issue that has been verified to require only test changes, not just a test failure.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bcmills@gopherbot

        Issue actions

          x/tools/gopls/test/debug: test fails when run in the module cache · Issue #59841 · golang/go