@@ -21,14 +21,13 @@ import (
21
21
"net/url"
22
22
"testing"
23
23
24
- "go.bug.st/relaxed-semver"
25
-
26
24
"github.com/arduino/arduino-cli/arduino/cores"
27
25
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
28
26
"github.com/arduino/arduino-cli/configs"
29
27
"github.com/arduino/go-paths-helper"
30
28
"github.com/arduino/go-properties-orderedmap"
31
29
"github.com/stretchr/testify/require"
30
+ semver "go.bug.st/relaxed-semver"
32
31
)
33
32
34
33
var customHardware = paths .New ("testdata" , "custom_hardware" )
@@ -102,6 +101,7 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
102
101
}
103
102
loadIndex ("https://dl.espressif.com/dl/package_esp32_index.json" )
104
103
loadIndex ("http://arduino.esp8266.com/stable/package_esp8266com_index.json" )
104
+ loadIndex ("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" )
105
105
require .NoError (t , pm .LoadHardware (conf ))
106
106
esp32 , err := pm .FindBoardWithFQBN ("esp32:esp32:esp32" )
107
107
require .NoError (t , err )
@@ -138,4 +138,28 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
138
138
testConflictingToolsInDifferentPackages ()
139
139
testConflictingToolsInDifferentPackages ()
140
140
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 )
141
165
}
0 commit comments