diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d3cbe4cac0c13c2766fcff1e2ad0bcec0a01bdd..7d81619af6ad36058d0c91d5c44398a64ef942b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ string(REGEX REPLACE "\n" "" OCTLIBS "${OCTLIBS}") string(REGEX REPLACE " " ";" OCTLIBS "${OCTLIBS}") set(MAOXDB_DIR "${PROJECT_SOURCE_DIR}/src/lib") -add_library(maoxdb STATIC "${MAOXDB_DIR}/test.cpp" "${MAOXDB_DIR}/maoxdb.cpp") +add_library(maoxdb STATIC "${MAOXDB_DIR}/maoxdb.cpp") set_target_properties(maoxdb PROPERTIES PUBLIC_HEADER "${MAOXDB_DIR}/maoxdb.hpp") target_compile_options(maoxdb PRIVATE "-I${OCTINCLUDEDIR}") get_property(_MAOX_LIB_DIR TARGET maoxdb PROPERTY LIBRARY_OUTPUT_DIRECTORY) @@ -179,14 +179,19 @@ endif() option(TEST "Unit test with gtest" OFF) if(TEST) - enable_testing() + # cmake tests suffers from not being able to define dependencies, see + # https://stackoverflow.com/questions/733475, so we disable it for now. + # enable_testing() + add_custom_target(test + echo "[EE] \\`make test\\` does not exist, did you mean \\`make test_detailed\\`?" + COMMAND exit 1) # append all the test cases here (file name without the ".cpp" suffix) set(test_cases test_utilities ) - # add special cmake functions for gtest + # add special cmake functions for gtest, (although they are not used yet, see above) include(GoogleTest) - # `make testfiles` shall just build the tests, `make test` builds and runs the tests + # `make testfiles` just builds the tests, `make test_detailed` builds and runs the tests add_custom_target(testfiles) add_custom_target(test_detailed DEPENDS testfiles) # loop over all test cases and add them to the test runner @@ -194,7 +199,7 @@ if(TEST) math(EXPR len_test_cases "${len_test_cases} - 1") foreach (i RANGE "${len_test_cases}") list(GET test_cases ${i} test_case_name) - # Use this instead, once cmake 3.14 is available everywhere. + # Once cmake 3.14 is available everywhere, use the new `foreach` instead. # foreach (test_case_name "${test_cases}") message(STATUS "test_case_name: ${test_case_name}") add_executable(${test_case_name} EXCLUDE_FROM_ALL test/${test_case_name}.cpp) @@ -209,12 +214,6 @@ if(TEST) maoxdb ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST}) target_link_directories(${test_case_name} PUBLIC ${OCTLIBDIR}) target_link_options(${test_case_name} PUBLIC ${OCTLIBS}) - if(_LINTING) - set_target_properties(${test_case_name} - PROPERTIES - CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY};${_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS}" - CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}") - endif() message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") gtest_discover_tests(${test_case_name} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" diff --git a/src/lib/maoxdb.cpp b/src/lib/maoxdb.cpp index 0e6dfa155df02fec9ffe5321e22e4061d5611439..7c8ffce7d00402178dacd7e09ffcbce56b52d25a 100644 --- a/src/lib/maoxdb.cpp +++ b/src/lib/maoxdb.cpp @@ -26,6 +26,7 @@ */ #include "maoxdb.hpp" +#include "mex.h" #include "caosdb/status_code.h" namespace maoxdb { diff --git a/src/lib/maoxdb.hpp b/src/lib/maoxdb.hpp index 044313e22d507a7aa84e621a7bb7018029f37355..29f98b8ec9a30085f979fe953d0ff92c04cfa6d9 100644 --- a/src/lib/maoxdb.hpp +++ b/src/lib/maoxdb.hpp @@ -4,7 +4,6 @@ #include "caosdb/exceptions.h" #include "caosdb/status_code.h" #include "mex.h" -#include "mexproto.h" #include <string> // Macros ///////////////////////////////////////////////////////////////////// diff --git a/src/lib/test.cpp b/src/lib/test.cpp deleted file mode 100644 index 6b871fff6774428aa9d8fbf2eb2418878093b334..0000000000000000000000000000000000000000 --- a/src/lib/test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "maoxdb.hpp" -#include "mex.h" -#include "mexproto.h" - -namespace maoxdb { - -void test() { - // do nothing. - auto *mx_str = mxCreateString("Hello World!"); -} - -} // namespace maoxdb diff --git a/src/private/maox_caosdb.cpp b/src/private/maox_caosdb.cpp index 5fbc38a7d49affa1f15553c636102a2f7f1e4372..c706ed8a23d8348bd46bdc511d67b6760a5ddfdd 100644 --- a/src/private/maox_caosdb.cpp +++ b/src/private/maox_caosdb.cpp @@ -2,7 +2,6 @@ #include "caosdb/constants.h" // for LIBCAOSDB_VERSION_MAJOR, LIBCAOSDB_VE... #include "caosdb/info.h" // for VersionInfo #include "mex.h" // for mxArray, mexFunction -#include "mexproto.h" // for mexPrintf, mxCreateString, mxGetChars #include <cstring> // for strcmp #include <memory> // for unique_ptr, __shared_ptr_access, shar... #include <string> // for allocator, char_traits, operator+ diff --git a/src/private/maox_info.cpp b/src/private/maox_info.cpp index 226e280167165c5aadc9914da24b2b61b824cc30..172e7d95685dd335b00b0c76dc4bbcb07f077c21 100644 --- a/src/private/maox_info.cpp +++ b/src/private/maox_info.cpp @@ -4,7 +4,6 @@ #include "caosdb/info.h" // for VersionInfo #include "maoxdb.hpp" // caosDB utils for mex files #include "mex.h" // for mxArray, mexFunction -#include "mexproto.h" // for mexPrintf, mxCreateString, mxGetChars #include <cstring> // for strcmp #include <memory> // for unique_ptr, __shared_ptr_access, shar... #include <string> // for allocator, char_traits, operator+ diff --git a/test/Makefile b/test/Makefile index 9b968c941d76ee46a3cd15470e3bcf57c40a0770..589bc4a3682344def4d8bbc3d3f234e4218edc20 100644 --- a/test/Makefile +++ b/test/Makefile @@ -43,13 +43,19 @@ test_octave: octave Run_Test.m .PHONY: test_octave + +# && make test || echo "Test(s) failed."; exit 1 test_cpp: $(eval BUILD_DIR ::= $(shell mktemp -d build_XXXXXXXX)) cd $(BUILD_DIR) \ && conan install ../.. -s "compiler.libcxx=libstdc++11" \ && cmake -D TEST=On ../.. \ - && make test || echo "Test(s) failed."; exit 1 - # && make test || make test_detailed || echo "Test(s) failed." ; exit 1 - # rm -r $(BUILD_DIR) + && make test_detailed \ + || echo "Test(s) failed."; exit 1 +# Exit with error if tests fail. +# && make test || make test_detailed || echo "Test(s) failed." ; exit 1 + +# Cleanup if everything went fine. + rm -r $(BUILD_DIR) .PHONY: test_cpp diff --git a/test/test_utilities.cpp b/test/test_utilities.cpp index bcbcfde33db06867cb7907fd897262cc158f2a16..3c7bc1a8d364956492e7b8b2c352a3fec82f3d23 100644 --- a/test/test_utilities.cpp +++ b/test/test_utilities.cpp @@ -28,8 +28,8 @@ namespace maoxdb { TEST(test_utilities, scalar_arrays) { mxArray *uint64_scalar; uint64_scalar = mxScalarUINT64(1); - EXPECT_TRUE(mxIsUint64(uint64_scalar));{ - EXXPECT_EQ(mxGetNumberOfElements(uint64_scalar), 1); + EXPECT_TRUE(mxIsUint64(uint64_scalar)); + EXPECT_EQ(mxGetNumberOfElements(uint64_scalar), 1); EXPECT_EQ(*((UINT64_T *) mxGetData(uint64_scalar)), 1); }