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

Vscode debug test and run test use two and more go.buildTags fail #1836

Open
ken0911208818 opened this issue Oct 13, 2021 · 4 comments
Open
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension.

Comments

@ken0911208818
Copy link

ken0911208818 commented Oct 13, 2021

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.
    • go1.16.6 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.7.2
golang.org/x/tools/[email protected] h1:kRKKdvA8GOzra8rhSFDClOR7hV/x8v0J0Vm4C/gWq8s=
github.com/BurntSushi/[email protected] h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
github.com/google/[email protected] h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/[email protected] h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/[email protected] h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
golang.org/x/[email protected] h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY=
golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/[email protected] h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
mvdan.cc/[email protected] h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
mvdan.cc/xurls/[email protected] h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • Version: 1.60.2 (Universal)
      Commit: 7f6ab5485bbc008386c4386d08766667e155244e
      Date: 2021-09-22T11:59:27.195Z
      Electron: 13.1.8
      Chrome: 91.0.4472.164
      Node.js: 14.16.0
      V8: 9.1.269.39-electron.0
      OS: Darwin arm64 20.4.0
  • Check your installed extensions to get the version of the VS Code Go extension

  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

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.

Describe the bug

one go.buildTags can run run test and debug test
two and more build tags Cannot be executed at the same time when using run test debug test

Steps to reproduce the behavior:

  1. Go to set settings.json go.buildTags "sqlite sqlite_unlock_notify"
  2. Click on run test debug test
  3. See error

Screenshots or recordings

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

problem

Vscode use run test and debug test
I use build tags to run test func
build tags: sqlite, sqlite_unlock_notify

In Vscode settings go.buiildTags use sqlite sqlite_unlock_notify run test can work but debug test not work

In Vscode settings go.buiildTags use 'sqlite sqlite_unlock_notify' run test not work but debug test can work

I need a method so that the above run test debug test can be executed together

@gopherbot gopherbot added this to the Untriaged milestone Oct 13, 2021
@hyangah hyangah added Debug Issues related to the debugging functionality of the extension. and removed Debug Issues related to the debugging functionality of the extension. labels Oct 14, 2021
@suzmue suzmue added the Debug Issues related to the debugging functionality of the extension. label Oct 18, 2021
@suzmue suzmue modified the milestones: Untriaged, Unplanned Oct 18, 2021
@vboulineau
Copy link

Hello,

Came across the exact same issue today and it was not straightforward to identify the failure was related to this as the errors message were only:

package jmx is not in GOROOT (/usr/local/opt/go/libexec/src/jmx)
package jetson is not in GOROOT (/usr/local/opt/go/libexec/src/jetson)
...
package zlib is not in GOROOT (/usr/local/opt/go/libexec/src/zlib)

Each package being one of the build tags. On top of that there's no significant diff between the command run:

/usr/local/opt/go/libexec/bin/go test -timeout 30s -tags ec2 jmx jetson orchestrator zlib systemd etcd consul secrets containerd cri docker apm kubelet python kubeapiserver gce netcgo zk process test -run

And with debug test:

go test -c -o /var/folders/h4/xp6zgrvd5_32n33jl3v53wt00000gn/T/__debug_bin3762757146 -gcflags all=-N -l -tags ec2 jmx jetson orchestrator zlib systemd etcd consul secrets containerd cri docker apm kubelet python kubeapiserver gce netcgo zk process test .

I guess that when passed through to Delve, the values do not belong to a single arg[] anymore and thus require some quoting but a quick look at the code did not allow me to find where this happens in the code exactly.

@polinasok polinasok added the debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test label Mar 30, 2022
@hkolvenbach
Copy link

hkolvenbach commented Jan 29, 2023

Any update on this? I am running into the exact same issue with multiple tags and @vboulineau describes the problem well: the build tags are not quoted and as such treated as individual arguments.

If one of the maintainers could point me to the location where the command line arguments are assembled, I could give it a shot with a PR. Is https://github.com/golang/vscode-go/blob/master/src/testUtils.ts#L136 the right place to look at?

Edit:
An ugly workaround would be to quote testTags yourself like this in settings.json

  "go.testTags": "'sqllite sqlite_unlock_notify'"

This allows debugging the tests, but running them fails unless the quotes are removed again.

@hyangah
Copy link
Contributor

hyangah commented Jan 30, 2023

Does the problem still exist if a comma-separated build tag list is used? From go command doc, space-separated list is deprecated.

        -tags tag,list
                a comma-separated list of additional build tags to consider satisfied
                during the build. For more information about build tags, see
                'go help buildconstraint'. (Earlier versions of Go used a
                space-separated list, and that form is deprecated but still recognized.)

I think

const buildFlags = tags ? ['-tags', tags] : [];
and
buildFlags: buildFlags.join(' '),
are relevant lines to fiddle with the debug args.

Or, once we make a progress in go-delve/delve#2718 passing the build flag as []string is another option.

@hkolvenbach
Copy link

Sorry for the late reply. Yes, comma-separated works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension.
Projects
None yet
Development

No branches or pull requests

7 participants