@@ -21,14 +21,13 @@ import (
2121 "net/url"
2222 "testing"
2323
24- "go.bug.st/relaxed-semver"
25-
2624 "github.com/arduino/arduino-cli/arduino/cores"
2725 "github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2826 "github.com/arduino/arduino-cli/configs"
2927 "github.com/arduino/go-paths-helper"
3028 "github.com/arduino/go-properties-orderedmap"
3129 "github.com/stretchr/testify/require"
30+ semver "go.bug.st/relaxed-semver"
3231)
3332
3433var customHardware = paths .New ("testdata" , "custom_hardware" )
@@ -102,6 +101,7 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
102101 }
103102 loadIndex ("https://dl.espressif.com/dl/package_esp32_index.json" )
104103 loadIndex ("http://arduino.esp8266.com/stable/package_esp8266com_index.json" )
104+ loadIndex ("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" )
105105 require .NoError (t , pm .LoadHardware (conf ))
106106 esp32 , err := pm .FindBoardWithFQBN ("esp32:esp32:esp32" )
107107 require .NoError (t , err )
@@ -138,4 +138,28 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
138138 testConflictingToolsInDifferentPackages ()
139139 testConflictingToolsInDifferentPackages ()
140140 testConflictingToolsInDifferentPackages ()
141+
142+ feather , err := pm .FindBoardWithFQBN ("adafruit:samd:adafruit_feather_m0_express" )
143+ require .NoError (t , err )
144+ require .NotNil (t , feather )
145+ featherTools , err := pm .FindToolsRequiredForBoard (feather )
146+ require .NoError (t , err )
147+ require .NotNil (t , featherTools )
148+
149+ // Test when a package index requires two different version of the same tool
150+ // See: https://github.com/arduino/arduino-cli/issues/166#issuecomment-528295989
151+ bossac17 := pm .FindToolDependency (& cores.ToolDependency {
152+ ToolPackager : "arduino" ,
153+ ToolName : "bossac" ,
154+ ToolVersion : semver .ParseRelaxed ("1.7.0" ),
155+ })
156+ require .NotNil (t , bossac17 )
157+ bossac18 := pm .FindToolDependency (& cores.ToolDependency {
158+ ToolPackager : "arduino" ,
159+ ToolName : "bossac" ,
160+ ToolVersion : semver .ParseRelaxed ("1.8.0-48-gb176eee" ),
161+ })
162+ require .NotNil (t , bossac18 )
163+ require .Contains (t , featherTools , bossac17 )
164+ require .Contains (t , featherTools , bossac18 )
141165}
0 commit comments