# # This file is a part of the CaosDB Project. # # Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> # Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # # append all the test cases here (file name without the ".cpp" suffix) set(test_cases test_connection test_utils ) # download gtest library #include(FetchGTest) # add special cmake functions for gtest include(GoogleTest) # disable linting for gtest targets (not our concern) #set_target_properties(gmock_main gmock gtest gtest_main PROPERTIES #CXX_CLANG_TIDY "" #CXX_INCLUDE_WHAT_YOU_USE "" #EXCLUDE_FROM_ALL 1) # loop over all test cases and add them to the test runner list(LENGTH test_cases len_test_cases) math(EXPR len_test_cases "${len_test_cases} - 1") foreach (i RANGE "${len_test_cases}") list(GET test_cases ${i} test_case_name) add_executable(${test_case_name} ${test_case_name}.cpp) target_link_libraries(${test_case_name} PRIVATE caosdb ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST}) set_target_properties(${test_case_name} PROPERTIES CXX_CLANG_TIDY "") gtest_discover_tests(${test_case_name} PROPERTIES LABELS "caosdb-cpplib-unit-tests") endforeach () # code coverage report include(CodeCoverage) if (LCOV_PATH) setup_target_for_coverage_lcov( NAME unit_test_coverage EXECUTABLE ctest -L caosdb-cpplib-unit-tests EXCLUDE "${CMAKE_BINARY_DIR}/*" DEPENDENCIES caosdb ${test_cases} LCOV_ARGS --rc lcov_branch_coverage=1 --no-external GENHTML_ARGS --rc lcov_branch_coverage=1 ) else () message(WARNING "Could not generate code coverage report. Please install lcov.") endif ()