Skip to content

Commit

Permalink
dap: clean output executable name for windows (go-delve#2514)
Browse files Browse the repository at this point in the history
If the output binary name does not end with .exe, it can't run on Windows
in noDebug mode. If user-provided output name doesn't have file extension
name (.exe), append it.

Fixes golang/vscode-go#1473
  • Loading branch information
hyangah authored May 27, 2021
1 parent 9de0030 commit 0e5b815
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion service/dap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,9 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
if mode == "debug" || mode == "test" {
output, ok := request.Arguments["output"].(string)
if !ok || output == "" {
output = cleanExeName(defaultDebugBinary)
output = defaultDebugBinary
}
output = cleanExeName(output)
debugbinary, err := filepath.Abs(output)
if err != nil {
s.sendInternalErrorResponse(request.Seq, err.Error())
Expand Down
4 changes: 2 additions & 2 deletions service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,7 @@ func TestLaunchRequestNoDebug_GoodStatus(t *testing.T) {
"noDebug": true,
"mode": "debug",
"program": fixture.Source,
"output": cleanExeName("__mybin")})
"output": "__mybin"})
}, fixture.Source, []int{8}, 0)
})
}
Expand All @@ -3494,7 +3494,7 @@ func TestLaunchRequestNoDebug_BadStatus(t *testing.T) {
"noDebug": true,
"mode": "debug",
"program": fixture.Source,
"output": cleanExeName("__mybin")})
"output": "__mybin"})
}, fixture.Source, []int{8}, 2)
})
}
Expand Down

0 comments on commit 0e5b815

Please sign in to comment.