From 8662d22a747f7026ecf9deba0664677f4880b9b7 Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Wed, 8 Sep 2021 11:19:27 +0200 Subject: [PATCH] ENH: Introduce ccaosdb version function and use in test --- src/CaosDB.jl | 2 +- src/Utility.jl | 20 +++++++++++++++++++- test/runtests.jl | 16 +--------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/CaosDB.jl b/src/CaosDB.jl index 6122a0b..3f0811a 100644 --- a/src/CaosDB.jl +++ b/src/CaosDB.jl @@ -29,7 +29,7 @@ export evaluate_return_code, CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage # Exports from module Utility -export get_env_fallback +export get_ccaosdb_version, get_env_fallback # Export from module Connection export connect, connect_manually diff --git a/src/Utility.jl b/src/Utility.jl index 4f74dcd..d9364e5 100644 --- a/src/Utility.jl +++ b/src/Utility.jl @@ -22,7 +22,7 @@ # module Utility -export get_env_fallback +export get_ccaosdb_version, get_env_fallback using ..CaosDB @@ -47,4 +47,22 @@ function get_env_fallback(var::AbstractString, default::AbstractString = "") end +""" + function get_ccaosdb_version() + +Return the version of the CaosDB C interface that is used by +CaosDB.jl. +""" +function get_ccaosdb_version() + + major = + ccall((:caosdb_constants_LIBCAOSDB_VERSION_MAJOR, CaosDB.library_name), Cint, ()) + minor = + ccall((:caosdb_constants_LIBCAOSDB_VERSION_MINOR, CaosDB.library_name), Cint, ()) + patch = + ccall((:caosdb_constants_LIBCAOSDB_VERSION_PATCH, CaosDB.library_name), Cint, ()) + + return VersionNumber("$major.$minor.$patch") +end + end # Utility diff --git a/test/runtests.jl b/test/runtests.jl index 89ec363..5bccba5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -25,21 +25,7 @@ using CaosDB @testset "CaosDBUnitTests" begin @testset "TestCaosdbCppLibVersion" begin - @test ccall( - (:caosdb_constants_LIBCAOSDB_VERSION_MAJOR, CaosDB.library_name), - Cint, - () - ) == 0 - @test ccall( - (:caosdb_constants_LIBCAOSDB_VERSION_MINOR, CaosDB.library_name), - Cint, - () - ) == 0 - @test ccall( - (:caosdb_constants_LIBCAOSDB_VERSION_PATCH, CaosDB.library_name), - Cint, - () - ) == 16 + @test CaosDB.Utility.get_ccaosdb_version() >= v"0.0.16" end @testset "TestUtility" begin -- GitLab