Skip to content

Commit 8065455

Browse files
committed
debug: fixed test runner
1 parent d28f6df commit 8065455

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

commands/debug/debug.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,7 @@ func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out
109109

110110
// getCommandLine compose a debug command represented by a core recipe
111111
func getCommandLine(req *dbg.DebugConfigReq, pm *packagemanager.PackageManager) ([]string, error) {
112-
debugInfo, err := GetDebugConfig(context.Background(), &dbg.DebugConfigReq{
113-
Instance: req.GetInstance(),
114-
Fqbn: req.GetFqbn(),
115-
SketchPath: req.GetSketchPath(),
116-
ImportDir: req.GetImportDir(),
117-
Port: req.GetPort(),
118-
})
112+
debugInfo, err := getDebugProperties(req, pm)
119113
if err != nil {
120114
return nil, err
121115
}

commands/debug/debug_info.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,10 @@ import (
3737
func GetDebugConfig(ctx context.Context, req *debug.DebugConfigReq) (*debug.GetDebugConfigResp, error) {
3838
pm := commands.GetPackageManager(req.GetInstance().GetId())
3939

40-
props, err := getDebugProperties(req, pm)
41-
if err != nil {
42-
return nil, err
43-
}
44-
45-
server := props.Get("server")
46-
toolchain := props.Get("toolchain")
47-
resp := &debug.GetDebugConfigResp{
48-
Executable: props.Get("executable"),
49-
Server: server,
50-
ServerPath: props.Get("server." + server + ".path"),
51-
ServerConfiguration: props.SubTree("server." + server).AsMap(),
52-
Toolchain: toolchain,
53-
ToolchainPath: props.Get("toolchain.path"),
54-
ToolchainPrefix: props.Get("toolchain.prefix"),
55-
ToolchainConfiguration: props.SubTree("toolchain." + toolchain).AsMap(),
56-
}
57-
return resp, nil
40+
return getDebugProperties(req, pm)
5841
}
5942

60-
func getDebugProperties(req *debug.DebugConfigReq, pm *packagemanager.PackageManager) (*properties.Map, error) {
43+
func getDebugProperties(req *debug.DebugConfigReq, pm *packagemanager.PackageManager) (*debug.GetDebugConfigResp, error) {
6144
// TODO: make a generic function to extract sketch from request
6245
// and remove duplication in commands/compile.go
6346
if req.GetSketchPath() == "" {
@@ -157,5 +140,16 @@ func getDebugProperties(req *debug.DebugConfigReq, pm *packagemanager.PackageMan
157140
return nil, status.Error(codes.Unimplemented, fmt.Sprintf("debugging not supported for board %s", req.GetFqbn()))
158141
}
159142

160-
return debugProperties, nil
143+
server := debugProperties.Get("server")
144+
toolchain := debugProperties.Get("toolchain")
145+
return &debug.GetDebugConfigResp{
146+
Executable: debugProperties.Get("executable"),
147+
Server: server,
148+
ServerPath: debugProperties.Get("server." + server + ".path"),
149+
ServerConfiguration: debugProperties.SubTree("server." + server).AsMap(),
150+
Toolchain: toolchain,
151+
ToolchainPath: debugProperties.Get("toolchain.path"),
152+
ToolchainPrefix: debugProperties.Get("toolchain.prefix"),
153+
ToolchainConfiguration: debugProperties.SubTree("toolchain." + toolchain).AsMap(),
154+
}, nil
161155
}

0 commit comments

Comments
 (0)