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