Skip to content

go.testFlags doesn't pass items before -args to debug binaries #1636

Closed
@mgabeler-lee-6rs

Description

@mgabeler-lee-6rs

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

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.16.6 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.7.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.58.2 c3f126316369cd610563c75b1b1725e0679adfb3 x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.26.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /home/mgl/src/go
GOROOT: /usr/lib/go-1.16
PATH: /home/mgl/.nodenv/shims:/usr/lib/ccache:/home/mgl/src/mgl-incident-tools/bin:/home/mgl/bin:/home/mgl/.local/bin:/home/mgl/.nodenv/bin:/home/mgl/src/go/bin:/sbin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/mgl/.npm/bin

   gopkgs: /home/mgl/src/go/bin/gopkgs installed
   go-outline: /home/mgl/src/go/bin/go-outline installed
   gotests: /home/mgl/src/go/bin/gotests installed
   gomodifytags: gomodifytags not installed
   impl: /home/mgl/src/go/bin/impl installed
   goplay: /home/mgl/src/go/bin/goplay installed
   dlv: /home/mgl/src/go/bin/dlv installed
   dlv-dap: dlv-dap not installed
   staticcheck: /home/mgl/src/go/bin/staticcheck installed
   gopls: /home/mgl/src/go/bin/gopls installed

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.useLanguageServer": true,
  "go.gotoSymbol.includeImports": true,
  "go.buildOnSave": "workspace",
  "go.lintOnSave": "workspace",
  "go.vetOnSave": "workspace",
  "go.testOnSave": true,
  "go.testTimeout": "10s",
  "go.delveConfig": {
    "dlvLoadConfig": {
      "followPointers": true,
      "maxVariableRecurse": 1,
      "maxStringLen": 1024,
      "maxArrayValues": 1024,
      "maxStructFields": -1
    },
    "apiVersion": 2,
    "showGlobalVariables": false
  },
  "go.testFlags": [
    "-v"
  ],
  "go.toolsManagement.autoUpdate": true,

Describe the bug

This is basically a re-hash / follow-up to old issue microsoft/vscode-go#2115

If you set go.testFlags to ["-v"], then you get verbose test output when running tests but not debugging them. If you set it to ["-args","-test.v"] then you get verbose output when debugging but not when running. You have to combine the two via ["-v", "-args", "-test.v"] to get both behaviors.

This is quite confusing. It seems that testFlags elements before -args ought to be passed to the debug binary with the test. prefix added, the same way go test does when non-debug running tests.

Steps to reproduce the behavior:

  1. Set go.testFlags to ["-v"]
  2. Select a test
  3. Set a breakpoint within it
  4. When the breakpoint hits, run ps auxww | grep test or such to see the running processes, observe that the test is run as /path/to/something.test -run ^TestName$, instead of as /path/to/something.test -run ^TestName$ -test.v

Metadata

Metadata

Assignees

Labels

DebugIssues related to the debugging functionality of the extension.Go CompanionIssues relating to the Go Companion extensionNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.debug/configIssues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions