diff --git a/legacy/builder/hardware_loader.go b/legacy/builder/hardware_loader.go index c1cfcbba1f7..1ea2fbfb6b8 100644 --- a/legacy/builder/hardware_loader.go +++ b/legacy/builder/hardware_loader.go @@ -50,11 +50,10 @@ func (s *HardwareLoader) Run(ctx *types.Context) error { pm := pmb.Build() pme, _ /* never release... */ := pm.NewExplorer() - - ctx.AllTools = pme.GetAllInstalledToolsReleases() ctx.PackageManager = pme } + ctx.AllTools = ctx.PackageManager.GetAllInstalledToolsReleases() ctx.Hardware = ctx.PackageManager.GetPackages() return nil } diff --git a/legacy/builder/test/tools_loader_test.go b/legacy/builder/test/tools_loader_test.go index 9d631822df4..2a40f69f168 100644 --- a/legacy/builder/test/tools_loader_test.go +++ b/legacy/builder/test/tools_loader_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/arduino/arduino-cli/arduino/cores" + "github.com/arduino/arduino-cli/arduino/cores/packagemanager" "github.com/arduino/arduino-cli/legacy/builder" "github.com/arduino/arduino-cli/legacy/builder/types" paths "github.com/arduino/go-paths-helper" @@ -179,3 +180,20 @@ func TestLoadLotsOfTools(t *testing.T) { require.Equal(t, "arduino:openocd@0.9.0-arduino", tools[idx].String()) requireEquivalentPaths(t, tools[idx].InstallDir.String(), "downloaded_board_manager_stuff/arduino/tools/openocd/0.9.0-arduino") } + +func TestAllToolsContextIsPopulated(t *testing.T) { + pmb := packagemanager.NewBuilder(nil, nil, nil, nil, "") + pmb.LoadHardwareFromDirectories(paths.NewPathList("downloaded_board_manager_stuff")) + pmb.LoadToolsFromBundleDirectory(paths.New("downloaded_tools", "tools_builtin")) + pm := pmb.Build() + pme, release := pm.NewExplorer() + defer release() + + ctx := &types.Context{ + PackageManager: pme, + } + + hl := &builder.HardwareLoader{} + require.NoError(t, hl.Run(ctx)) + require.NotEmpty(t, ctx.AllTools) +}