-
Notifications
You must be signed in to change notification settings - Fork 764
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
go.testFlags doesn't pass items before -args to debug binaries #1636
Comments
I agree that this is confusing, though I'm not sure we can change the behavior at this point. We will discuss this in our triage meeting. For reference, would you find a separate configuration option for test arguments to be equally confusing? |
From my perspective, there's "flags for building the test binary", and "flags for running the test binary". I would like to be able to configure the latter once, and have them apply equally whether I'm running or debugging that binary. If having Also, poking around, I'm seeing some extra fun behavior where Which makes me think that making the use case of "I want vscode-go to always run my tests with verbose enabled" work without arcane invocations may simply require a special case no matter what (absent any changes to
|
We discussed this today, and consensus was that we can't change this behavior at this point: we can't break users who have configurations containing -args.
I'm not seeing this behavior. I see |
Hmm ... yeah, I think that was an artifact of caching, or more likely typos. Doing a more careful, isolated test (below), I'm finding that no variation on So it seems that, to reliably get verbose test output with the extension, the only way to do it right now is to double-request it by using I guess the question is, should the extension replicate how To me, having the extension act like More fiddly bits: Setup I'm working with:
package example
import "testing"
func TestDemo(t *testing.T) {
t.Log("verbose output")
}
I think the difference here is, subtly, captured by the
Confusing, but documented 🤷♂️ |
I fell on my face with this again trying to use the "Go Companion" extension. With the normal Go extension, the test explorer can still at least run tests with:
But the Go companion gets completely broken by having Can the code that handles the debug launches just "parse" Not being able to have |
If this is something that needs to be fixed, that needs to be fixed in Go, not this extension (or Go Companion). I will note that moving the package specifier to the end works:
It's already doing that. Debug launches are handled with I pushed v0.0.4 as a git tag which should trigger a release, though I only just set up the actions for that so I'm not 100% sure they'll work. |
To be clear, this is fixed by using Go Companion v0.0.4, not in vscode-go. Honestly I don't 100% follow the "doesn't pass items" part, but IIUC the issue you want solved is using With respect to the "doesn't pass items" part, Go Companion definitely passes items when doing a normal test run, and I fixed the order so that they're passed after the flags the extension sets like -fullpath. During a debug run, all test flags must be passed as args. That's the only way you can pass test flags to delve. Build flags are split out and passed with --build-flags, but all test flags must be prefixed and passed after --, as in: Additionally, Go Companion (and vscode-go's test explorer) always use the equivalent of -json/-v because without that I wouldn't be able to tell vscode when a test passes/fails/etc. |
That's about vscode-go, not Go Companion. This ticket predates the existence of Go Companion I think :) It sounds like Go Companion 0.4.0 will fix most of the problems here. The one that's left that I'm not clear on is the "Debug test" overlay/inlay hint decorated atop a test function declaration. That is the one that required the most shenanigans to get to run with verbose output mode. Does/will Go Companion take over that debug launch as well? Having to go find a test in the test explorer in order to do its debug launch right is ... not fun UX. Esp. when I'm finding that the Go Companion, at least at 0.3.0, tends to miss entire multiple entire packages within my workspace (that's a separate issue, of course) |
Yes. I knew it had a name but was failing to remember it :)
I'm just one person, but personally I find that code lens super useful. I'll give the preview version a try and see how having Go Companion take over the mentioned items goes. It sounds like it should be better & more consistent, thanks :) |
I've not worked out what any pattern is, so making a reproducer may be challenging, but I'll give it a go. FWIW, the vscode workspace in which I experienced this was a multi-folder one. The folder I was/am working in is itself a multi-module go workspace. But the package I first noticed missing was the one from the active editor window. To avoid confusing this issue any further, I'll try to narrow down this issue and make a new ticket if I can get anything coherent / reproducible. Edit: figured it out: golang/go#70929 |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Go from the VS Code integrated terminal.go version go1.16.6 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.7.0
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.1.58.2 c3f126316369cd610563c75b1b1725e0679adfb3 x64
0.26.0
Go: Locate Configured Go Tools
command.Checking configured tools....
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"]
orgopls
prefixes.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 thetest.
prefix added, the same waygo test
does when non-debug running tests.Steps to reproduce the behavior:
go.testFlags
to["-v"]
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
The text was updated successfully, but these errors were encountered: