Repository navigation
x/tools/gopls: no action for TestMain #59067
Description
What version of Go are you using (go version)?
go version go1.19.6 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pedro/.cache/go-build"
GOENV="/home/pedro/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pedro/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pedro/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pedro/Documents/Escola/Mestrado/2semestre/CC/projeto_individual/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3618416135=/tmp/go-build -gno-record-gcc-switches"
What did you do?
In VSCode when I try to create a TestMain function with the *testing.M nothing appears on top of it to run the test, as shown in the first picture. However, if I change it to something else, like T or even nothing it appears. I don't believe that it is my problem.
What did you expect to see?
A "run test" clickable text on top of the function
What did you see instead?
The "run test" clickable test does not appear


Activity
[-]affected/package: db[/-][+]x/tools/gopls: no action for TestMain[/+]findleyr commentedon Mar 24, 2023
We can definitely produce code lenses here, though I think VS Code would also need an update to their middleware to actually invoke the test.
CC @hyangah
pfcouto commentedon Mar 24, 2023
If you need anything else from me, just @ me and I will be at your disposal. Thanks for the help!
hyangah commentedon Mar 24, 2023
Related: golang/vscode-go#482
VS Code does not use gopls's test code lenses. The intention was not to present a code lens on
TestMain(*testing.M)and obviously it didn't take into account the case where it's actively edited. (another related: golang/vscode-go#2435)For package-level testing, there is "run package tests" codelens.