From b1687958b19a7fb73f69f67e726780a8e255c8ed Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Wed, 7 Jul 2021 15:40:38 +0200 Subject: [PATCH] ENH: Replace dummy function by libcaosdb version retrieval --- jlcaosdb/jlcaosdb.cxx | 8 +++++++- src/CaosDB.jl | 20 ++++++++++++++------ test/runtests.jl | 11 ++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/jlcaosdb/jlcaosdb.cxx b/jlcaosdb/jlcaosdb.cxx index 15986d4..37543e1 100644 --- a/jlcaosdb/jlcaosdb.cxx +++ b/jlcaosdb/jlcaosdb.cxx @@ -22,9 +22,15 @@ */ #include <jlcxx/jlcxx.hpp> +#include "caosdb/authentication.h" #include "caosdb/connection.h" +#include "caosdb/constants.h" +#include "caosdb/exceptions.h" JLCXX_MODULE define_julia_module(jlcxx::Module& mod) { - + // Version info of libcaosdb against which this is built. + mod.method("get_libcaosdb_version_major", []() {return caosdb::LIBCAOSDB_VERSION_MAJOR;}); + mod.method("get_libcaosdb_version_minor", []() {return caosdb::LIBCAOSDB_VERSION_MINOR;}); + mod.method("get_libcaosdb_version_patch", []() {return caosdb::LIBCAOSDB_VERSION_PATCH;}); } diff --git a/src/CaosDB.jl b/src/CaosDB.jl index f17fb67..6b725fa 100644 --- a/src/CaosDB.jl +++ b/src/CaosDB.jl @@ -1,21 +1,29 @@ +# Useful for development, TODO remove for production +__precompile__(false) + module CaosDB using CxxWrap # Adapt this path if you haven't compiled jlcaosdb to `caosdb-julialib/build` -@wrapmodule(joinpath(pwd(), "build/lib/libjlcaosdb")) +@wrapmodule(joinpath(@__DIR__, "../jlcaosdb/build/lib/libjlcaosdb")) function __init__() @initcxx end -export dummy_func - """ - dummy_func(x) + get_libcaosdb_version() -Returns double the number `x` plus `1`. +Returns the version string of libcaosdb with which this package has +been built. """ -dummy_func(x) = 2x + 1 +function get_libcaosdb_version() + major = get_libcaosdb_version_major() + minor = get_libcaosdb_version_minor() + patch = get_libcaosdb_version_patch() + + return "$major.$minor.$patch" +end end # module diff --git a/test/runtests.jl b/test/runtests.jl index 04b3c1a..11c94af 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1 +1,10 @@ -println("Testing...") +using CaosDB +using Test + +# Test whether retrieving the libcaosdb version works as expected +@test CaosDB.get_libcaosdb_version() != Nothing +@test length(split(CaosDB.get_libcaosdb_version(), ".")) == 3 +@test split(CaosDB.get_libcaosdb_version(), ".")[1] == string(CaosDB.get_libcaosdb_version_major()) +@test split(CaosDB.get_libcaosdb_version(), ".")[2] == string(CaosDB.get_libcaosdb_version_minor()) +@test split(CaosDB.get_libcaosdb_version(), ".")[3] == string(CaosDB.get_libcaosdb_version_patch()) + -- GitLab