-
Notifications
You must be signed in to change notification settings - Fork 646
Fix buildFlags type in 'debug test' Codelens #1248
Fix buildFlags type in 'debug test' Codelens #1248
Conversation
src/goRunTestCodelens.ts
Outdated
@@ -85,7 +85,7 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider { | |||
buildFlags.push(`"${vsConfig['buildTags']}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is related to buildtags specifically and not buildflags in general, shouldnt we do the join that you did on line 85 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to usage and interface declaration, I'll check again, thanks.buildFlags
seems to assume a string?
, or is this reference place wrong(or not just Delve class)?
280e790
to
efc1d3d
Compare
Can you give me a sample code where I can test this? |
Problem:
// +build noci
package some
import "testing"
func TestFoo(t *testing.T) {
// A test always fail on CI sever
} Only when I add $ go test .
? github.com/ka2n/example/some [no test files]
$ go test -tags noci
ok github.com/ka2n/example/some 0.007s In VSCode, I want to add
{
"go.buildTags": "noci other_tag"
}
Running tool: /usr/local/Cellar/go/1.9/libexec/bin/go test -timeout 30s -tags noci other_tag -run ^TestFoo$
PASS
ok github.com/ka2n/example/some 0.006s
Success: Tests passed.
To check final argument to launch delv, log It output:
To fix this problem I added this commit. Second problem is something different situation, but I noted here for someone's reference. I want to add "go.buildTags:" "noci other_tag",
"go.buildFlags": [
"-ldflags",
"-X mypackage.myvalue=./"
] run
In this situation, I've try to solve this problem, got partial success, but it make |
I spent an hour trying to reproduce your first problem, but couldnt repro. Turns out this is not an issue in Windows. Then I tried on my Mac and was able to repro the issue instantly. So, please confirm, the problem seems to be that delve requires buildFlags to be a single string which is space separated and In that case, your initial solution of converting the entire |
@ramya-rao-a At first, my initial solution was not correct to solve entire problem. So, my latest commit is focus on just For both issues correct {
"go.buildFlags": [
"-tags",
"noci other_tag",
"-ldFlags",
"-X mypackage.myvalue=./"
]
}
But I can't find a way to filter argument value and quote it for Delv arguments. |
Hey, my mistake, I am able to see the issue in Windows as well. I made a commit to your branch for quoting both the flags and the flag values and that seem to work well for all cases
Both "run tests" and "debug tests" codelens should now work. Can you give it a try? |
I've tested with macOS( Thank you! |
Awesome, thanks for working on this @ka2n |
Make the type of buildArgs executed by Codelens consistent with LaunchRequestArguments.
This fix the problem that
go.buildTags
is ignored bydebug test
.