From 95cfd654fe0dd6b07e903d3132c0faceabfbe9e3 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 19 Feb 2024 14:15:51 +0100 Subject: [PATCH] Allow optional programmer in debug (#2540) --- commands/debug/debug_info.go | 17 ++++++++--------- commands/debug/debug_test.go | 6 ------ internal/integrationtest/debug/debug_test.go | 3 --- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/commands/debug/debug_info.go b/commands/debug/debug_info.go index 2ed1387280c..1855b8bb716 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -169,15 +169,14 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl } } - if req.GetProgrammer() == "" { - return nil, &arduino.MissingProgrammerError{} - } - if p, ok := platformRelease.Programmers[req.GetProgrammer()]; ok { - toolProperties.Merge(p.Properties) - } else if refP, ok := referencedPlatformRelease.Programmers[req.GetProgrammer()]; ok { - toolProperties.Merge(refP.Properties) - } else { - return nil, &arduino.ProgrammerNotFoundError{Programmer: req.GetProgrammer()} + if req.GetProgrammer() != "" { + if p, ok := platformRelease.Programmers[req.GetProgrammer()]; ok { + toolProperties.Merge(p.Properties) + } else if refP, ok := referencedPlatformRelease.Programmers[req.GetProgrammer()]; ok { + toolProperties.Merge(refP.Properties) + } else { + return nil, &arduino.ProgrammerNotFoundError{Programmer: req.GetProgrammer()} + } } var importPath *paths.Path diff --git a/commands/debug/debug_test.go b/commands/debug/debug_test.go index fbb61626144..6d7a0505e20 100644 --- a/commands/debug/debug_test.go +++ b/commands/debug/debug_test.go @@ -65,12 +65,6 @@ func TestGetCommandLine(t *testing.T) { pme, release := pm.NewExplorer() defer release() - { - // Check programmer required - _, err := getCommandLine(req, pme) - require.Error(t, err) - } - { // Check programmer not found req.Programmer = "not-existent" diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index 12d4c514e78..f8483d0f814 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -336,9 +336,6 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli } func testDebugCheck(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) { - _, _, err := cli.Run("debug", "check", "-b", "arduino:samd:mkr1000") - require.Error(t, err) - out, _, err := cli.Run("debug", "check", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice") require.NoError(t, err) require.Contains(t, string(out), "The given board/programmer configuration supports debugging.")