11using Test
22using Pkg, Base. BinaryPlatforms
33using BinaryBuilderBase
4- using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec
4+ using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec, cached_git_clone
55using JSON
6+ using LibGit2
67
78# Define equality between dependencies, in order to carry out the tests below
89Base.:(== )(a:: AbstractDependency , b:: AbstractDependency ) = getpkg (a) == getpkg (b)
179180 platform = Platform (" x86_64" , " linux" ; julia_version= v " 1.5" )
180181
181182 # Test that a particular version of GMP is installed
182- ap = @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
183+ @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
183184 @test isfile (joinpath (destdir (dir, platform), " lib" , " libgmp.so.10.3.2" ))
184185 end
185186
190191 platform = Platform (" x86_64" , " linux" ; julia_version= v " 1.6" )
191192
192193 # Test that a particular version of GMP is installed
193- ap = @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
194+ @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
194195 @test isfile (joinpath (destdir (dir, platform), " lib" , " libgmp.so.10.4.0" ))
195196 end
196197
@@ -204,16 +205,53 @@ end
204205
205206 # Test that this is not instantiatable with either Julia v1.5 or v1.6
206207 platform = Platform (" x86_64" , " linux" ; julia_version= v " 1.5" )
207- ap = @test_throws Pkg. Resolve. ResolverError setup_dependencies (prefix, getpkg .(dependencies), platform)
208+ @test_throws Pkg. Resolve. ResolverError setup_dependencies (prefix, getpkg .(dependencies), platform)
208209 platform = Platform (" x86_64" , " linux" ; julia_version= v " 1.6" )
209- ap = @test_throws Pkg. Resolve. ResolverError setup_dependencies (prefix, getpkg .(dependencies), platform)
210+ @test_throws Pkg. Resolve. ResolverError setup_dependencies (prefix, getpkg .(dependencies), platform)
210211
211212 # If we don't give a `julia_version`, then we are FULLY UNSHACKLED.
212213 platform = Platform (" x86_64" , " linux" )
213- ap = @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
214+ @test_logs setup_dependencies (prefix, getpkg .(dependencies), platform)
214215 @test isfile (joinpath (destdir (dir, platform), " lib" , " libgmp.so.10.3.2" ))
215216 @test isfile (joinpath (destdir (dir, platform), " lib" , " libmpfr.so.6.1.0" ))
216217 end
218+
219+ # Dependency as a local directory
220+ with_temp_project () do dir
221+ mktempdir () do pkgdir
222+ prefix = Prefix (dir)
223+ # Clone if necessary the remote repository and check out its
224+ # working directory in a temporary space.
225+ cache_dir = cached_git_clone (" https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl" )
226+ LibGit2. with (LibGit2. clone (cache_dir, pkgdir)) do repo
227+ LibGit2. checkout! (repo, " c7f2e95d9c04e218931c14954ecd31ebde72cca5" )
228+ end
229+ dependencies = [
230+ PackageSpec (
231+ name= " HelloWorldC_jll" ,
232+ path= pkgdir,
233+ ),
234+ ]
235+ platform = Platform (" x86_64" , " linux" ; libc= " glibc" )
236+ @test_logs setup_dependencies (prefix, dependencies, platform)
237+ @test readdir (joinpath (destdir (dir, platform), " bin" )) == [" hello_world" ]
238+ end
239+ end
240+
241+ # Dependency as a remote repository
242+ with_temp_project () do dir
243+ prefix = Prefix (dir)
244+ dependencies = [
245+ PackageSpec (
246+ name= " HelloWorldC_jll" ,
247+ url= " https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl" ,
248+ rev= " c7f2e95d9c04e218931c14954ecd31ebde72cca5" ,
249+ ),
250+ ]
251+ platform = Platform (" x86_64" , " linux" ; libc= " glibc" )
252+ @test_logs setup_dependencies (prefix, dependencies, platform)
253+ @test readdir (joinpath (destdir (dir, platform), " bin" )) == [" hello_world" ]
254+ end
217255 end
218256end
219257
0 commit comments