Skip to content

Failure to debug a suite test that is in a different file than the caller test #2414

Closed
@nirhaas

Description

@nirhaas

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
go version go1.18.1 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.9.3
    golang.org/x/tools/[email protected] h1:wfh4cfJAKwOG49sCE4ldafYeD5rlejE/gJQ7JAR5yX0=
    github.com/BurntSushi/[email protected] h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
    github.com/google/[email protected] h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
    github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp/[email protected] h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
    golang.org/x/[email protected] h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
    golang.org/x/[email protected] h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
    golang.org/x/[email protected] h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
    golang.org/x/[email protected] h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
    golang.org/x/[email protected] h1:yg8cGxL0g/WIlkF25aKuIAZacqXROXw4Dt57iKLWg8w=
    golang.org/x/[email protected] h1:BkeW9/QJhcigekDUPS9N9bIb0v7gPKKmLYeczVAqr2s=
    honnef.co/go/[email protected] h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
    mvdan.cc/[email protected] h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
    mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.18.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.70.1
6d9b74a70ca9c7733b29f0456fd8195364076dda
arm64
  • Check your installed extensions to get the version of the VS Code Go extension
v0.35.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /Users/nhaas/go
GOROOT: /opt/homebrew/Cellar/go/1.18.1/libexec
PATH: /Users/nhaas/go/bin:/Users/nhaas/Library/Python/3.8/bin:/opt/homebrew/opt/libpq/bin:/Users/nhaas/.tgenv/bin:/Users/nhaas/.tfenv/bin:/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/nhaas/.cargo/bin:/Users/nhaas/.fzf/bin

	go:	/opt/homebrew/bin/go: go version go1.18.1 darwin/arm64

	gotests:	/Users/nhaas/go/bin/gotests	(version: v1.6.0 built with go: go1.18.1)
	gomodifytags:	/Users/nhaas/go/bin/gomodifytags	(version: v1.16.0 built with go: go1.18.1)
	impl:	/Users/nhaas/go/bin/impl	(version: v1.1.0 built with go: go1.18.1)
	goplay:	/Users/nhaas/go/bin/goplay	(version: v1.0.0 built with go: go1.18.1)
	dlv:	/Users/nhaas/go/bin/dlv	(version: v1.8.3 built with go: go1.18.1)
	golangci-lint:	/Users/nhaas/go/bin/golangci-lint	(version: v1.48.0 built with go: go1.18.1)
	gopls:	/Users/nhaas/go/bin/gopls	(version: v0.9.3 built with go: go1.18.1)

go env
Workspace Folder (vscode-go): /Users/nhaas/Temp/vscode-go
	GO111MODULE=""
	GOARCH="arm64"
	GOBIN=""
	GOCACHE="/Users/nhaas/Library/Caches/go-build"
	GOENV="/Users/nhaas/Library/Application Support/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="arm64"
	GOHOSTOS="darwin"
	GOINSECURE=""
	GOMODCACHE="/Users/nhaas/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="darwin"
	GOPATH="/Users/nhaas/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/opt/homebrew/Cellar/go/1.18.1/libexec"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/opt/homebrew/Cellar/go/1.18.1/libexec/pkg/tool/darwin_arm64"
	GOVCS=""
	GOVERSION="go1.18.1"
	GCCGO="gccgo"
	AR="ar"
	CC="clang"
	CXX="clang++"
	CGO_ENABLED="1"
	GOMOD="/Users/nhaas/Temp/vscode-go/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t8/83vffqv11_bbfxbbdc3fsfx40000gn/T/go-build4218516277=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

  "go.lintTool": "golangci-lint",
  "go.formatTool": "gosimports",
  "go.formatFlags": ["-local", "github.com/company"],
  "gopls": {
    "ui.semanticTokens": true
  },

Describe the bug

Terminology: When using testify suite, there is

  1. The suite itself (struct)
  2. The suite tests (test functions)
  3. A normal test that runs suite.Run with the suite struct.

Following #1130, when clicking the button to "Debug test" for a suite test that is in a different file than the "normal test", we never stop at the breakpoint, and get testing: warning: no tests to run printed on the debug console.

I suspect that the reason for this behavior is that the function findAllTestSuiteRuns (

export function findAllTestSuiteRuns(
) only has access to the document symbols when trying to figure out whether there is a suite.Run. If the "normal test" is in a different file (which is different document), it returns an empty array, which would later be parsed to a wrong -test.run flag to dlv.

From dlv log output (note that ^$):

2022-08-15T21:51:57+03:00 debug layer=dap parsed launch config: {
	"mode": "test",
	"program": ".",
	"args": [
		"-test.run",
		"^$",
		"-testify.m",
		"^TestSomething$"
	],
	"env": {
		"GOPATH": "/Users/nhaas/go"
	},
	"backend": "default",
	"stackTraceDepth": 50
}

Steps to reproduce the behavior:

Follow the steps of #1130 and try to click "Debug test" for a suite test in the other file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebugIssues related to the debugging functionality of the extension.go-testissues related to go test support (test output, test explorer, ...)

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions