From fcea13eef8a2f6ae6c72f9caa9d3f8f9c7a19e57 Mon Sep 17 00:00:00 2001 From: Martina Rivizzigno Date: Mon, 14 Oct 2019 17:29:35 +0200 Subject: [PATCH] add gtest, temp disable swig (cherry picked from commit 4008d163d77f503e6acbd7ddc1d87ac6d479c897) --- CMakeLists.txt | 27 +++++++++++++++++++++------ EKF/CMakeLists.txt | 12 ++++++------ test/main.cpp | 7 +++++++ test/test_example.cpp | 7 +++++++ 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 test/main.cpp create mode 100644 test/test_example.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a5fb4b2437..f6c257f922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) add_compile_options( -pedantic - + -Wall -Wextra -Werror @@ -102,7 +102,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) # testing include(CTest) enable_testing() - + if(BUILD_TESTING) option(ECL_TESTS "Build ECL tests" ON) @@ -196,17 +196,17 @@ endif() if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) option(BUILD_DOXYGEN "Build doxygen documentation" OFF) - + if (BUILD_DOXYGEN) find_package(Doxygen) if (DOXYGEN_FOUND) # set input and output files set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - + # request to configure the file configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - + # note the option ALL which allows to build the docs together with the application add_custom_target(doxygen ALL COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} @@ -216,9 +216,24 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) VERBATIM USES_TERMINAL ) - + else() message(FATAL_ERROR "Doxygen needs to be installed to generate documentation") endif() endif() endif() + + +enable_testing() +include_directories(${GTEST_INCLUDE_DIR}) +add_subdirectory("/usr/src/gtest" ${CMAKE_BINARY_DIR}/gtest) + +set(SRCS + test/main.cpp + test/test_example.cpp + ) +add_executable(TestECL ${SRCS}) + +target_include_directories(TestECL PRIVATE ${GTEST_INCLUDE_DIRS}) +target_link_libraries(TestECL gtest gtest_main) +add_test(NAME TestECL COMMAND TestECL) diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index ea458d67cb..3a51f8b4ba 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -58,10 +58,10 @@ set_target_properties(ecl_EKF PROPERTIES PUBLIC_HEADER "ekf.h") target_compile_options(ecl_EKF PRIVATE -fno-associative-math) -if(EKF_PYTHON_TESTS) - add_subdirectory(swig) -endif() +#if(EKF_PYTHON_TESTS) +# add_subdirectory(swig) +#endif() -if(BUILD_TESTING) - add_subdirectory(tests) -endif() +#if(BUILD_TESTING) +# add_subdirectory(tests) +#endif() diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000000..3f40e107b0 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + std::cout << "init test \n"; + return RUN_ALL_TESTS(); +} diff --git a/test/test_example.cpp b/test/test_example.cpp new file mode 100644 index 0000000000..f06369aaca --- /dev/null +++ b/test/test_example.cpp @@ -0,0 +1,7 @@ +#include "gtest/gtest.h" + +TEST(test_example, sample_test) +{ + printf("blabla \n" ); + EXPECT_EQ(1, 1); +}