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

test: incorrect absolute test failure path reported through deferred helper func #3525

Closed
exodustx0 opened this issue Sep 4, 2024 · 3 comments
Labels
Duplicate Make it obvious when issues are closed as duplicate go-test issues related to go test support (test output, test explorer, ...)

Comments

@exodustx0
Copy link

exodustx0 commented Sep 4, 2024

gopls version

Build info
----------
golang.org/x/tools/gopls v0.16.1
	golang.org/x/tools/gopls@v0.16.1 h1:1hO/dCeUvjEYx3V0rVvCtOkwnpEpqS29paE+Jw4dcAc=
	github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
	github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
	golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
	golang.org/x/mod@v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
	golang.org/x/sync@v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
	golang.org/x/sys@v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
	golang.org/x/telemetry@v0.0.0-20240607193123-221703e18637 h1:3Wt8mZlbFwG8llny+t18kh7AXxyWePFycXMuVdHxnyM=
	golang.org/x/text@v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
	golang.org/x/tools@v0.22.1-0.20240628205440-9c895dd76b34 h1:Kd+Z5Pm6uwYx3T2KEkeHMHUMZxDPb/q6b1m+zEcy62c=
	golang.org/x/vuln@v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
	honnef.co/go/tools@v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
	mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
	mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.0

go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Exodust\AppData\Local\go-build
set GOENV=C:\Users\Exodust\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Exodust\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Exodust\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23.0
set GODEBUG=
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\Exodust\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Exodust\go\src\github.com\exodustx0\testingbug\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\Exodust\AppData\Local\Temp\go-build3098519217=/tmp/go-build -gno-record-gcc-switches

What did you do?

package bug_test

import "testing"

func TestWrongFilename(t *testing.T) {
	defer func() {
		t.Helper()
		t.Fatal("foo")
	}()
	println([]byte{}[0])
}

(Playground, doesn't fail in the Playground due to the absence of gopls test commands)

The report produced by the run test command incorrectly assumes that the test failure originated from the work directory. In this instance, the test failure originates from runtime/panic.go:115, but run test reports it as being <workdir>/panic.go:115.

What did you see happen?

Running tool: C:\Program Files\Go\bin\go.exe test -timeout 30s -coverprofile=C:\Users\Exodust\AppData\Local\Temp\vscode-goWsftAN\go-code-cover -run ^TestWrongFilename$ github.com/exodustx0/testingbug

--- FAIL: TestWrongFilename (0.00s)
    c:\Users\Exodust\go\src\github.com\exodustx0\testingbug\panic.go:115: foo
FAIL
coverage: [no statements]
FAIL	github.com/exodustx0/testingbug	0.201s
FAIL

What did you expect to see?

Running tool: C:\Program Files\Go\bin\go.exe test -timeout 30s -coverprofile=C:\Users\Exodust\AppData\Local\Temp\vscode-goWsftAN\go-code-cover -run ^TestWrongFilename$ github.com/exodustx0/testingbug

--- FAIL: TestWrongFilename (0.00s)
    c:\Program Files\Go\src\runtime\panic.go:115: foo
FAIL
coverage: [no statements]
FAIL	github.com/exodustx0/testingbug	0.201s
FAIL

Editor and settings

VSCode 1.92.2

settings.json:

{
    "gopls": {
        "formatting.gofumpt": true,
        "ui.diagnostic.staticcheck": true,
        "ui.documentation.linksInHover": "gopls"
    },
}

Logs

2024/09/04 13:11:29 Info:2024/09/04 13:11:29 Created View (#1)
        directory=C:\Users\Exodust\go\src\github.com\exodustx0\testingbug
        view_type="GoMod"
        root_dir="file:///C:/Users/Exodust/go/src/github.com/exodustx0/testingbug"
        go_version="go version go1.23.0 windows/amd64"
        build_flags=[]
        env={GOOS:windows GOARCH:amd64 GOCACHE:C:\Users\Exodust\AppData\Local\go-build GOMODCACHE:C:\Users\Exodust\go\pkg\mod GOPATH:C:\Users\Exodust\go GOPRIVATE: GOFLAGS: GO111MODULE: GOTOOLCHAIN:auto GoVersion:23 G
oVersionOutput:go version go1.23.0 windows/amd64
 ExplicitGOWORK: EffectiveGOPACKAGESDRIVER:}
        env_overlay=[]
2024/09/04 13:11:31 Info:2024/09/04 13:11:31 go/packages.Load golang/go#1
        view_id="1"
        snapshot=0
        directory=C:\Users\Exodust\go\src\github.com\exodustx0\testingbug
        query=[C:\Users\Exodust\go\src\github.com\exodustx0\testingbug\... builtin]
        packages=4
        duration=1.5106045s
@exodustx0 exodustx0 added the gopls gopls related issues label Sep 4, 2024
@findleyr
Copy link
Member

findleyr commented Sep 5, 2024

CC @hyangah

I believe this logic lives in vscode-go, not gopls.

@hyangah hyangah transferred this issue from golang/go Sep 5, 2024
@hyangah hyangah added go-test issues related to go test support (test output, test explorer, ...) and removed gopls gopls related issues labels Sep 5, 2024
@hyangah hyangah changed the title x/tools/gopls: incorrect absolute test failure path reported through deferred helper func test: incorrect absolute test failure path reported through deferred helper func Sep 5, 2024
@hyangah
Copy link
Contributor

hyangah commented Sep 5, 2024

Actually this is a duplicate of #2444 and #2622.
I think we can try the -fullpath flag (golang/go#37708 available from go1.21).

Closing in favor of #2444

@hyangah hyangah closed this as completed Sep 5, 2024
@hyangah hyangah added the Duplicate Make it obvious when issues are closed as duplicate label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Make it obvious when issues are closed as duplicate go-test issues related to go test support (test output, test explorer, ...)
Projects
None yet
Development

No branches or pull requests

4 participants