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 Explorer: test logging in another package results in wrong file path in Test Output #2444

Open
MadTyres opened this issue Sep 8, 2022 · 2 comments
Labels
go-test issues related to go test support (test output, test explorer, ...) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@MadTyres
Copy link

MadTyres commented Sep 8, 2022

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

@gopherbot gopherbot added this to the Untriaged milestone Sep 8, 2022
@adonovan adonovan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 8, 2022
@hyangah hyangah added the go-test issues related to go test support (test output, test explorer, ...) label Sep 29, 2022
@suzmue suzmue modified the milestones: Untriaged, vscode-go/later Oct 3, 2022
@DojinPark
Copy link

Still present in 2024, VSCode Go v0.41.2

@firelizzard18
Copy link
Contributor

This should be addressed by #3523 (with go test -fullpath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go-test issues related to go test support (test output, test explorer, ...) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: No status
Development

No branches or pull requests

7 participants