extension/src/goTest: preserve buildFlags as array when debugging tests#4035
extension/src/goTest: preserve buildFlags as array when debugging tests#4035vrv501 wants to merge 1 commit into
Conversation
|
This PR (HEAD: 9f43132) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/vscode-go/+/781820. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/781820. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/781820. |
|
Message from Vaibhav: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/781820. |
The debugTestAtCursor CodeLens previously joined go.buildFlags into a
single space-separated string before passing them to the debug adapter.
This corrupted flag values that contain spaces, such as
-ldflags "-X pkg.version=v1.0": after joining, delve sees -X and
pkg.version=v1.0 as separate arguments and fails with "with multiple
packages, -o must refer to a directory or /dev/null".
Meanwhile, the run-test CodeLens passes each flag as a separate
argument to go test, so the same go.buildFlags worked for "run test"
but broke "debug test".
Fix:
Pass buildFlags as an array to startDebugging. The existing
maybeJoinFlags helper in goDebugConfiguration.ts already handles both
shapes: it joins for delve < 1.22.2 and preserves the array for newer
delve, so each element reaches delve as a separate token. Also omit
buildFlags from the debug config when empty to keep behavior parity
with the previous "" sentinel.
Fixes #3933