-
Notifications
You must be signed in to change notification settings - Fork 762
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
debug test fails when go.testFlags has gcflags #2953
Comments
Related: #128 |
Edited the original message to include the repro repo link. |
I found the issue, https://github.com/golang/vscode-go/blob/master/src/goDebugConfiguration.ts#L396. The regexp does not allow whitespaces without quotes. I tried doing this in my {
"go.toolsManagement.autoUpdate": true,
"go.testFlags": ["-gcflags='all=-N -l'"],
"go.testOnSave": true
} but this will fail codelen's "run test" Running tool: /usr/local/go/bin/go test -timeout 30s -run ^TestToTest$ example.com -gcflags='all=-N -l'
invalid value "'all=-N -l'" for flag -gcflags: parameter may not start with quote character '
usage: go test [build/test flags] [packages] [build/test flags & test binary flags]
Run 'go help test' and 'go help testflag' for details. Proposal for fixI believe it's difficult to write the regexp to capture this case because the // in goDebugConfiguration.ts
// Remove any '--gcflags' entries and show a warning
if (debugConfiguration['buildFlags']) {
const resp = this.removeGcflags(debugConfiguration['buildFlags']);
if (resp.removed) {
debugConfiguration['buildFlags'] = resp.args;
this.showWarning(
'ignoreDebugGCFlagsWarning',
"User specified build flag '--gcflags' in 'buildFlags' is being ignored (see [debugging with build flags](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#specifying-other-build-flags) documentation)"
);
}
} // in goTest.ts
const workspaceFolder = vscode.workspace.getWorkspaceFolder(doc.uri);
const debugConfig: vscode.DebugConfiguration = {
name: 'Debug Test',
type: 'go',
request: 'launch',
mode: 'test',
program: path.dirname(doc.fileName),
env: goConfig.get('testEnvVars', {}),
envFile: goConfig.get('testEnvFile'),
args,
buildFlags: buildFlags.join(' '), // don't .join()
sessionID
}; I can raise the fix. EDIT: This may not work because we use the same way to get rid of gcflags from ['env']['GOFLAGS']. |
As a workaround for anyone else encountering this. Splitting -N and -l into separate -gcflags works. {
"go.testFlags": ["-gcflags=all=-N", "-gcflags=all=-l"],
} |
it works, thank you very much. |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/[email protected] h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/[email protected] h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/[email protected] h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/[email protected] h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/[email protected] h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/[email protected] h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/[email protected] h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/[email protected] h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDdvANnk=
golang.org/x/[email protected] h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
honnef.co/go/[email protected] h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
mvdan.cc/[email protected] h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.4
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.6445d93c81ebe42c4cbd7a60712e0b17d9463e97
x64
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"]
orgopls
prefixes.Describe the bug
A clear and concise description of what the bug.
With gcflags set in go.testFlags. Using debug test in codelens results in an error.
Seems like the flags are passed to delve even though there's a prompt saying that it will be ignored.
Moreover, even if the flags are passed to delve, it shouldn't return an error due to what seems like a parsing issue.
My guess is that somehow we're not catching the gcflags correctly due to some parsing, hence both errors.
A clear and concise description of what you expected to happen.
Running debug test in codelens should run tests in debug mode even if we have gcflags configured in go.testFlags.
Steps to reproduce the behavior:
main_test.go
, and run "debug test" using codelensScreenshots or recordings
Pardon the low quality gif to illustrate the issue
The text was updated successfully, but these errors were encountered: