@@ -300,3 +300,49 @@ func TestCompileWithEsp32BundledLibraries(t *testing.T) {
300
300
}
301
301
require .NotContains (t , string (stdout ), expectedOutput [0 ]+ "\n " + expectedOutput [1 ]+ "\n " + expectedOutput [2 ]+ "\n " )
302
302
}
303
+
304
+ func TestCompileWithEsp8266BundledLibraries (t * testing.T ) {
305
+ // Some esp cores have have bundled libraries that are optimize for that architecture,
306
+ // it might happen that if the user has a library with the same name installed conflicts
307
+ // can ensue and the wrong library is used for compilation, thus it fails.
308
+ // This happens because for "historical" reasons these platform have their "name" key
309
+ // in the "library.properties" flag suffixed with "(esp32)" or similar even though that
310
+ // doesn't respect the libraries specification.
311
+ // https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
312
+ //
313
+ // The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
314
+ // that would have caused the libraries that are both bundled with the core and the Java IDE to be
315
+ // always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
316
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
317
+ defer env .CleanUp ()
318
+
319
+ _ , _ , err := cli .Run ("update" )
320
+ require .NoError (t , err )
321
+
322
+ // Update index with esp8266 core and install it
323
+ url := "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
324
+ coreVersion := "2.7.4"
325
+ _ , _ , err = cli .Run ("core" , "update-index" , "--additional-urls=" + url )
326
+ require .NoError (t , err )
327
+ _ , _ , err = cli .Run ("core" , "install" , "esp8266:esp8266@" + coreVersion , "--additional-urls=" + url )
328
+ require .NoError (t , err )
329
+
330
+ // Install a library with the same name as one bundled with the core
331
+ _ , _ , err = cli .Run ("lib" , "install" , "SD" )
332
+ require .NoError (t , err )
333
+
334
+ sketchPath := cli .CopySketch ("sketch_with_sd_library" )
335
+ fqbn := "esp8266:esp8266:generic"
336
+
337
+ stdout , _ , err := cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--verbose" )
338
+ require .Error (t , err )
339
+
340
+ coreBundledLibPath := cli .DataDir ().Join ("packages" , "esp8266" , "hardware" , "esp8266" , coreVersion , "libraries" , "SD" )
341
+ cliInstalledLibPath := cli .SketchbookDir ().Join ("libraries" , "SD" )
342
+ expectedOutput := [3 ]string {
343
+ "Multiple libraries were found for \" OneWire.h\" " ,
344
+ " Used: " + coreBundledLibPath .String (),
345
+ " Not used: " + cliInstalledLibPath .String (),
346
+ }
347
+ require .NotContains (t , string (stdout ), expectedOutput [0 ]+ "\n " + expectedOutput [1 ]+ "\n " + expectedOutput [2 ]+ "\n " )
348
+ }
0 commit comments