From b93c639460e8198f9ce05955b5cbdbd3fc82d5c6 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 19 Feb 2024 14:47:10 +0100 Subject: [PATCH] Allow optional programmer in debug (#2544) This is a cherry-pick of https://github.com/arduino/arduino-cli/pull/2540 from the 0.35.x branch --- 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 b392ab6401c..5528dd53b8f 100644 --- a/commands/debug/debug_info.go +++ b/commands/debug/debug_info.go @@ -154,15 +154,14 @@ func getDebugProperties(req *rpc.GetDebugConfigRequest, pme *packagemanager.Expl } } - if req.GetProgrammer() == "" { - return nil, &cmderrors.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, &cmderrors.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, &cmderrors.ProgrammerNotFoundError{Programmer: req.GetProgrammer()} + } } var importPath *paths.Path diff --git a/commands/debug/debug_test.go b/commands/debug/debug_test.go index 09d4e4f6362..9ca9d7cf056 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 096fb6e7717..ffb95766b22 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.")