Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bcmills opened this issue Apr 26, 2023 · 3 comments
Closed

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

bcmills opened this issue Apr 26, 2023 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Apr 26, 2023

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/[email protected]/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
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 26, 2023
@gopherbot gopherbot added this to the Unreleased milestone Apr 26, 2023
@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 26, 2023
@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

gopherbot pushed a commit to golang/tools that referenced this issue Apr 27, 2023
Detecting the go version does not require build flags,
and should not depend on the value of GO111MODULE.

For golang/go#59841.

Change-Id: I74255953985e6d2ad01095eea2b6d72f7d280e3f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/489215
Run-TryBot: Bryan Mills <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
gopls-CI: kokoro <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
@golang golang locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants