@@ -287,6 +287,8 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
287
287
loadIndex ("https://dl.espressif.com/dl/package_esp32_index.json" )
288
288
loadIndex ("http://arduino.esp8266.com/stable/package_esp8266com_index.json" )
289
289
loadIndex ("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json" )
290
+ loadIndex ("https://test.com/package_test_index.json" )
291
+
290
292
// We ignore the errors returned since they might not be necessarily blocking
291
293
// but just warnings for the user, like in the case a board is not loaded
292
294
// because of malformed menus
@@ -310,8 +312,13 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
310
312
})
311
313
require .NotNil (t , esptool0413 )
312
314
315
+ testPlatform := pme .FindPlatformRelease (& packagemanager.PlatformReference {
316
+ Package : "test" ,
317
+ PlatformArchitecture : "avr" ,
318
+ PlatformVersion : semver .MustParse ("1.1.0" )})
319
+
313
320
testConflictingToolsInDifferentPackages := func () {
314
- tools , err := pme .FindToolsRequiredForBoard (esp32 )
321
+ tools , err := pme .FindToolsRequiredForBuild (esp32 . PlatformRelease , nil )
315
322
require .NoError (t , err )
316
323
require .Contains (t , tools , esptool231 )
317
324
require .NotContains (t , tools , esptool0413 )
@@ -331,10 +338,44 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
331
338
testConflictingToolsInDifferentPackages ()
332
339
testConflictingToolsInDifferentPackages ()
333
340
341
+ {
342
+ // Test buildPlatform dependencies
343
+ arduinoBossac180 := pme .FindToolDependency (& cores.ToolDependency {
344
+ ToolPackager : "arduino" ,
345
+ ToolName : "bossac" ,
346
+ ToolVersion : semver .ParseRelaxed ("1.8.0-48-gb176eee" ),
347
+ })
348
+ require .NotNil (t , arduinoBossac180 )
349
+ testBossac175 := pme .FindToolDependency (& cores.ToolDependency {
350
+ ToolPackager : "test" ,
351
+ ToolName : "bossac" ,
352
+ ToolVersion : semver .ParseRelaxed ("1.7.5" ),
353
+ })
354
+ require .NotNil (t , testBossac175 )
355
+
356
+ tools , err := pme .FindToolsRequiredForBuild (esp32 .PlatformRelease , nil )
357
+ require .NoError (t , err )
358
+ require .Contains (t , tools , esptool231 )
359
+ require .NotContains (t , tools , esptool0413 )
360
+ // When building without testPlatform dependency, arduino:bossac should be selected
361
+ // since it has the higher version
362
+ require .NotContains (t , tools , testBossac175 )
363
+ require .Contains (t , tools , arduinoBossac180 )
364
+
365
+ tools , err = pme .FindToolsRequiredForBuild (esp32 .PlatformRelease , testPlatform )
366
+ require .NoError (t , err )
367
+ require .Contains (t , tools , esptool231 )
368
+ require .NotContains (t , tools , esptool0413 )
369
+ // When building with testPlatform dependency, test:bossac should be selected
370
+ // because it has dependency priority
371
+ require .Contains (t , tools , testBossac175 )
372
+ require .NotContains (t , tools , arduinoBossac180 )
373
+ }
374
+
334
375
feather , err := pme .FindBoardWithFQBN ("adafruit:samd:adafruit_feather_m0_express" )
335
376
require .NoError (t , err )
336
377
require .NotNil (t , feather )
337
- featherTools , err := pme .FindToolsRequiredForBoard (feather )
378
+ featherTools , err := pme .FindToolsRequiredForBuild (feather . PlatformRelease , nil )
338
379
require .NoError (t , err )
339
380
require .NotNil (t , featherTools )
340
381
0 commit comments