Skip to content

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

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

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

Comments

@pavlelee
Copy link
Contributor

pavlelee commented Mar 4, 2022

gopls version

Build info

golang.org/x/tools/gopls v0.8.0
golang.org/x/tools/[email protected] h1:a71KO95TfIvCCMQJrZBSQIGQ9lkc0kWL+dSlEdZd7HI=
github.com/BurntSushi/[email protected] h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/google/[email protected] h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/[email protected] h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/[email protected] h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/[email protected] h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/[email protected] h1:UVkOvSIhR/pX6OflsXS9hsDvaUJn8SLHqTlvdfUDiNo=
golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/[email protected] h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
mvdan.cc/[email protected] h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
mvdan.cc/xurls/[email protected] 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 gopls related issues labels Mar 4, 2022
@pavlelee
Copy link
Contributor Author

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 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
Collaborator

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

@golang golang locked and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls gopls related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants