Skip to content

Test Explorer: test logging in another package results in wrong file path in Test Output #2444

Open
@MadTyres

Description

@MadTyres

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.

    • 1.19.1
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • golang.org/x/tools/gopls v0.9.4
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.71.0, arm64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.35.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    go: /Users/mathiastg/go/bin/go: go version go1.19.1 darwin/arm64

    gotests: /Users/mathiastg/go/bin/gotests (version: v1.6.0 built with go: go1.19.1)
    gomodifytags: /Users/mathiastg/go/bin/gomodifytags (version: v1.16.0 built with go: go1.19.1)
    impl: /Users/mathiastg/go/bin/impl (version: v1.1.0 built with go: go1.19.1)
    goplay: /Users/mathiastg/go/bin/goplay (version: v1.0.0 built with go: go1.19.1)
    dlv: /Users/mathiastg/go/bin/dlv (version: v1.9.1 built with go: go1.19.1)
    staticcheck: /Users/mathiastg/go/bin/staticcheck (version: v0.3.3 built with go: go1.19.1)
    gopls: /Users/mathiastg/go/bin/gopls (version: v0.9.4 built with go: go1.19.1)

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.
"go.toolsManagement.autoUpdate": true
"go.testEnvFile": "${workspaceFolder}/local.env"

Describe the bug

Consider the file tree below

src
  └ tests
  | ├ helper_package
  | | └ helper.go
  | └ a_test.go

I have a test in a_test.go, that uses a helper function in helper_package.helper.go. This helper function logs some errors on t.Error.

I run the test in a_test.go using the Test Explorer.
VS Code tries to automatically GOTO the line in helper.go where I log something, but the file path is wrong.
VS Code redirects me to src/tests/helper.go, which doesn't exist, so it shows a prompt like the attached picture.
helper.go is placed in src/tests/helper_packages/helper.go.

I expected VS Code to redirect me to
src/tests/helper_package/helper.go

Steps to reproduce the behavior:

  1. Download the minimal_reproducible_project.zip
  2. Unzip it
  3. Open debug-tests-path in VS Code
  4. Use the Test Explorer to run the tests
  5. See the file not found error prompt
  6. Also see the Test Output terminal, which prints incorrect paths as well.

=== RUN   Test_A
    /Users/mathiastg/debug-tests-path/src/tests/helper.go:8: asd
--- FAIL: Test_A (0.00s)
FAIL
FAIL    gleerup.io/debug-tests/src/tests        0.103s


> Test run finished at 08/09/2022, 11:19:59 <

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

Screenshot 2022-09-08 at 10 58 35

Metadata

Metadata

Assignees

No one assigned

    Labels

    Go CompanionIssues relating to the Go Companion extensiongo-testissues related to go test support (test output, test explorer, ...)

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions