@@ -174,3 +174,43 @@ func TestRecompileWithDifferentLibrary(t *testing.T) {
174174 require .NoError (t , err )
175175 require .NotContains (t , string (stdout ), "Using previously compiled file: " + objPath .String ())
176176}
177+
178+ func TestCompileWithConflictingLibrariesInclude (t * testing.T ) {
179+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
180+ defer env .CleanUp ()
181+
182+ _ , _ , err := cli .Run ("update" )
183+ require .NoError (t , err )
184+
185+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr@1.8.3" )
186+ require .NoError (t , err )
187+
188+ // Installs conflicting libraries
189+ gitUrl := "https://github.com/pstolarz/OneWireNg.git"
190+ oneWireNgLibPath := cli .SketchbookDir ().Join ("libraries" , "onewireng_0_8_1" )
191+ _ , err = git .PlainClone (oneWireNgLibPath .String (), false , & git.CloneOptions {
192+ URL : gitUrl ,
193+ ReferenceName : plumbing .NewTagReferenceName ("0.8.1" ),
194+ })
195+ require .NoError (t , err )
196+
197+ gitUrl = "https://github.com/PaulStoffregen/OneWire.git"
198+ oneWireLibPath := cli .SketchbookDir ().Join ("libraries" , "onewire_2_3_5" )
199+ _ , err = git .PlainClone (oneWireLibPath .String (), false , & git.CloneOptions {
200+ URL : gitUrl ,
201+ ReferenceName : plumbing .NewTagReferenceName ("v2.3.5" ),
202+ })
203+ require .NoError (t , err )
204+
205+ sketchPath := cli .CopySketch ("sketch_with_conflicting_libraries_include" )
206+ fqbn := "arduino:avr:uno"
207+
208+ stdout , _ , err := cli .Run ("compile" , "-b" , fqbn , sketchPath .String (), "--verbose" )
209+ require .NoError (t , err )
210+ expectedOutput := [3 ]string {
211+ "Multiple libraries were found for \" OneWire.h\" " ,
212+ " Used: " + oneWireLibPath .String (),
213+ " Not used: " + oneWireNgLibPath .String (),
214+ }
215+ require .Contains (t , string (stdout ), expectedOutput [0 ]+ "\n " + expectedOutput [1 ]+ "\n " + expectedOutput [2 ]+ "\n " )
216+ }
0 commit comments