Skip to content

Commit

Permalink
Merge pull request zeromq#286 from kurdybacha/ctest_integration
Browse files Browse the repository at this point in the history
Problem zeromq#268: CTest output without tests details
  • Loading branch information
sigiesec authored Jan 28, 2019
2 parents 6a4fe1f + 6982fb7 commit 6639441
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 5 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})

include(CTest)
include(cmake/catch.cmake)
include(${CATCH_MODULE_PATH}/Catch.cmake)

find_package(Threads)

add_executable(
Expand All @@ -25,7 +28,7 @@ add_executable(

add_dependencies(unit_tests catch)

target_include_directories(unit_tests PUBLIC ${CATCH_INCLUDE_DIR})
target_include_directories(unit_tests PUBLIC ${CATCH_MODULE_PATH})
target_link_libraries(
unit_tests
PRIVATE cppzmq
Expand All @@ -39,9 +42,4 @@ if (COVERAGE)
target_link_libraries(unit_tests PRIVATE --coverage)
endif()

add_test(
NAME
unit
COMMAND
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/unit_tests
)
catch_discover_tests(unit_tests)
15 changes: 13 additions & 2 deletions tests/cmake/catch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ ExternalProject_Add(
DOWNLOAD_NO_EXTRACT ON
)

# Expose variable CATCH_INCLUDE_DIR to parent scope
# Expose variable CATCH_MODULE_PATH to parent scope
ExternalProject_Get_Property(catch DOWNLOAD_DIR)
set(CATCH_INCLUDE_DIR ${DOWNLOAD_DIR} CACHE INTERNAL "Path to include catch")
set(CATCH_MODULE_PATH ${DOWNLOAD_DIR} CACHE INTERNAL "Path to include catch")

# Download module for CTest integration
if(NOT EXISTS "${CATCH_MODULE_PATH}/Catch.cmake")
file(DOWNLOAD "https://raw.githubusercontent.com/catchorg/Catch2/master/contrib/Catch.cmake"
"${CATCH_MODULE_PATH}/Catch.cmake")
endif()
if(NOT EXISTS "${CATCH_MODULE_PATH}/CatchAddTests.cmake")
file(DOWNLOAD "https://raw.githubusercontent.com/catchorg/Catch2/master/contrib/CatchAddTests.cmake"
"${CATCH_MODULE_PATH}/CatchAddTests.cmake")
endif()

0 comments on commit 6639441

Please sign in to comment.