@@ -116,3 +116,48 @@ func TestCompilerErrOutput(t *testing.T) {
116
116
compilerErr := requirejson .Parse (t , out ).Query (".compiler_err" )
117
117
compilerErr .MustContain (`"error"` )
118
118
}
119
+
120
+ func TestCompileRelativeLibraryPath (t * testing.T ) {
121
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
122
+ defer env .CleanUp ()
123
+
124
+ // Initialize configs to enable --zip-path flag
125
+ _ , _ , err := cli .Run ("config" , "init" , "--dest-dir" , "." )
126
+ require .NoError (t , err )
127
+ _ , _ , err = cli .Run ("config" , "set" , "library.enable_unsafe_install" , "true" , "--config-file" , "arduino-cli.yaml" )
128
+ require .NoError (t , err )
129
+ configFile := cli .WorkingDir ().Join ("arduino-cli.yaml" )
130
+
131
+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr" )
132
+ require .NoError (t , err )
133
+
134
+ // Install library and its dependencies
135
+ zipPath , err := paths .New (".." , "testdata" , "FooLib.zip" ).Abs ()
136
+ require .NoError (t , err )
137
+ _ , _ , err = cli .Run ("lib" , "install" , "--zip-path" , zipPath .String (), "--config-file" , configFile .String ())
138
+ require .NoError (t , err )
139
+
140
+ // Uninstall library
141
+ _ , _ , err = cli .Run ("lib" , "uninstall" , "FooLib" )
142
+ require .NoError (t , err )
143
+
144
+ // Manually install the library and move into one of the example's directories
145
+ FooLib := cli .WorkingDir ().Join ("FooLib" )
146
+ err = paths .New (".." , "testdata" , "FooLib" ).CopyDirTo (FooLib )
147
+ require .NoError (t , err )
148
+ cli .SetWorkingDir (FooLib .Join ("examples" , "FooSketch" ))
149
+
150
+ // Compile using a relative path to the library
151
+ _ , _ , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--library" , "../../" )
152
+ require .NoError (t , err )
153
+
154
+ // Install the same library using lib install and compile again using the relative path.
155
+ // The manually installed library should be chosen
156
+ _ , _ , err = cli .Run ("lib" , "install" , "--zip-path" , zipPath .String (), "--config-file" , configFile .String ())
157
+ require .NoError (t , err )
158
+ stdout , _ , err := cli .Run ("compile" , "-b" , "arduino:avr:uno" , "--library" , "../../" , "-v" )
159
+ require .NoError (t , err )
160
+ require .Contains (t , string (stdout ), "Multiple libraries were found for \" FooLib.h\" " )
161
+ require .Contains (t , string (stdout ), "Used: " + FooLib .String ())
162
+ require .Contains (t , string (stdout ), "Not used: " + cli .SketchbookDir ().Join ("libraries" , "FooLib" ).String ())
163
+ }
0 commit comments