forked from JuliaPy/PyCall.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_build.jl
49 lines (43 loc) · 1.43 KB
/
test_build.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module TestPyCallBuild
include(joinpath(dirname(@__FILE__), "..", "deps", "depsutils.jl"))
include(joinpath(dirname(@__FILE__), "..", "deps", "buildutils.jl"))
using Test
@testset "find_libpython" begin
for python in ["python", "python2", "python3"]
if Sys.which(python) === nothing
@info "$python not available; skipping test"
else
@test isfile(find_libpython(python)[2])
end
end
# Test the case `find_libpython.py` does not print anything. We
# use the command `true` to mimic this case.
if Sys.which("true") === nothing
@info "no `true` command; skipping test"
else
let err, msg
@test try
find_libpython("true")
false
catch err
err isa ErrorException
end
msg = sprint(showerror, err)
@test occursin("Couldn't find libpython", msg)
@test occursin("ENV[\"PYCALL_DEBUG_BUILD\"] = \"yes\"", msg)
end
end
# Test the case `dlopen` failed to open the library.
let err, msg
@test try
find_libpython("python"; _dlopen = (_...) -> error("dummy"))
false
catch err
err isa ErrorException
end
msg = sprint(showerror, err)
@test occursin("Couldn't find libpython", msg)
@test occursin("ENV[\"PYCALL_DEBUG_BUILD\"] = \"yes\"", msg)
end
end
end # module