From 690c383452b2accf94465f3d3b5c6cd1ed72f37c Mon Sep 17 00:00:00 2001 From: Andy Nowacki Date: Tue, 23 May 2023 23:04:14 +0100 Subject: [PATCH] Add an environment for the separate test script The tests which are controlled by a script in `script/` previously relied on having somehow activated an environment with PyCall before running the script. Fix that so activating (and if needed instantiating) the environment can be done. Also update the hard-coded path to `libproj` in `GLWrapper.jl`. --- script/GLWrapper.jl | 2 +- script/Project.toml | 7 +++++++ script/test_GeodTest.jl | 24 +++++++++++++++--------- 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 script/Project.toml diff --git a/script/GLWrapper.jl b/script/GLWrapper.jl index b016c1f..dc42f13 100644 --- a/script/GLWrapper.jl +++ b/script/GLWrapper.jl @@ -23,7 +23,7 @@ export GeodGeodesic, geod_init, geod_inverse -const LIBGEOD = "/opt/local/lib/proj6/lib/libproj.dylib" +const LIBGEOD = "/opt/local/lib/proj9/lib/libproj.dylib" struct Cdouble6 x1::Cdouble diff --git a/script/Project.toml b/script/Project.toml new file mode 100644 index 0000000..1ca2feb --- /dev/null +++ b/script/Project.toml @@ -0,0 +1,7 @@ +[deps] +GeographicLib = "c96ba436-a6fe-11e9-10ab-c9f3919c93d1" +PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" + +[compat] +PyCall = "1" +julia = "1.6" diff --git a/script/test_GeodTest.jl b/script/test_GeodTest.jl index 9b2d1d4..d2c0059 100644 --- a/script/test_GeodTest.jl +++ b/script/test_GeodTest.jl @@ -1,8 +1,8 @@ -import Pkg, PyCall - -Pkg.activate(joinpath(@__DIR__, "..")) +import Pkg +Pkg.activate(@__DIR__) using GeographicLib +using PyCall include("GLWrapper.jl") import .GLWrapper @@ -34,8 +34,10 @@ and will take several minutes. - Karney, C. F. F. (2010). Test set for geodesics [Data set]. Zenodo. http://doi.org/10.5281/zenodo.32156 """ -function runtest(; verbose=true, python=false, rtol=1e-5, atol=1e-5) - geod_test_file = joinpath(@__DIR__, "GeodTest.dat") +function runtest(; + verbose=true, python=false, rtol=1e-5, atol=1e-5, + geod_test_file=joinpath(@__DIR__, "GeodTest.dat") +) if !isfile(geod_test_file) @info("Downloading 83 MB file to $geod_test_file") download("https://zenodo.org/record/32156/files/GeodTest.dat?download=1", @@ -83,7 +85,7 @@ function runtest(; verbose=true, python=false, rtol=1e-5, atol=1e-5) if python v_test_py = r_test_py["$f"] if not_equal(v_true, v_test_py, rtol=rtol, atol=atol) - push!(py_wrong_lines, (i=i, value=f, truth=v_true, v_test=v_test_py)) + push!(py_wrong_lines, (i=i, value=f, truth=v_true, test=v_test_py)) end end end @@ -92,9 +94,13 @@ function runtest(; verbose=true, python=false, rtol=1e-5, atol=1e-5) end errors = length(unique(w.i for w in wrong_lines)) errors_c = length(unique(w.i for w in c_wrong_lines)) - @info("Total Julia error lines: $errors") - @info("Total C error lines: $errors_c") - inputs, wrong_lines, c_wrong_lines, py_wrong_lines + errors_python = length(unique(w.i for w in py_wrong_lines)) + @info("Total Julia error lines: $errors") + @info("Total C error lines: $errors_c") + if python + @info("Total Python error lines: $errors_python") + end + (; inputs, wrong_lines, c_wrong_lines, py_wrong_lines) end !isinteractive() && abspath(PROGRAM_FILE) == abspath(@__FILE__) && runtest()