Skip to content

Commit

Permalink
Fixed compile regression (#1867)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 6, 2022
1 parent c2af7c5 commit a900cfb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions legacy/builder/hardware_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
18 changes: 18 additions & 0 deletions legacy/builder/test/tools_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -179,3 +180,20 @@ func TestLoadLotsOfTools(t *testing.T) {
require.Equal(t, "arduino:[email protected]", 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)
}

0 comments on commit a900cfb

Please sign in to comment.