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

goGenerateTests: failed to generate tests for methods after migration to gopls #2091

Closed
pavlelee opened this issue Mar 4, 2022 · 3 comments
Closed
Labels
gopls
Milestone

Comments

@pavlelee
Copy link
Contributor

@pavlelee pavlelee commented Mar 4, 2022

gopls version

Build info

golang.org/x/tools/gopls v0.8.0
golang.org/x/tools/gopls@v0.8.0 h1:a71KO95TfIvCCMQJrZBSQIGQ9lkc0kWL+dSlEdZd7HI=
github.com/BurntSushi/toml@v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/google/go-cmp@v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sys@v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/tools@v0.1.10-0.20220303153236-fa15af63a6f1 h1:UVkOvSIhR/pX6OflsXS9hsDvaUJn8SLHqTlvdfUDiNo=
golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/tools@v0.2.2 h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
mvdan.cc/gofumpt@v0.3.0 h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
go: go1.18rc1

go env

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/data/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOMODCACHE="/data/go/pkg/mod"
GOOS="linux"
GOPATH="/data/go"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

generate unit test for function

What did you expect to see?

generate unit test

What did you see instead?

image

Editor and settings

Logs

@gopherbot gopherbot added Tools gopls labels Mar 4, 2022
@pavlelee
Copy link
Contributor Author

@pavlelee pavlelee commented Mar 4, 2022

https://github.com/pavlelee/vscode-go/blob/acbe5034f931b88de0a22c7ed104a54567cefb84/src/goOutline.ts#L214
vscode-go extension call gopls vscode.executeDocumentSymbolProvider return method, go-outline return function

@hyangah
Copy link
Contributor

@hyangah hyangah commented Mar 4, 2022

Thank you so much for catching this! @pavlelee

This is a regression caused by replacement of go-outline with gopls.
The document symbol provider using go-outline marks methods as function, while gopls correctly marks methods as methods. The tests didn't catch this because for this test, languageClient and gopls was not initialized, so the old code path (that uses go-outline was used :-() I did manual testing. We will merge your PR and follow up with test fix. cc @suzmue

@hyangah hyangah changed the title x/tools/gopls: No function found at cursor when generate unit test for function goGenerateTests: failed to generate tests for methods after migration to gopls Mar 4, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 4, 2022

Change https://go.dev/cl/389994 mentions this issue: src/goGenerateTests: fix method can not generate test in gopls document symbol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls
Projects
None yet
Development

No branches or pull requests

3 participants