use ctest for testing
This commit is contained in:
@ -9,59 +9,37 @@ set (CMAKE_CXX_STANDARD 14)
|
||||
|
||||
option(USE_TLS "Add TLS support" ON)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
||||
../third_party
|
||||
../third_party/msgpack11
|
||||
../ws
|
||||
)
|
||||
|
||||
add_definitions(-DSPDLOG_COMPILED_LIB=1)
|
||||
|
||||
find_package(JsonCpp)
|
||||
if (NOT JSONCPP_FOUND)
|
||||
include_directories(../third_party/jsoncpp)
|
||||
set(JSONCPP_SOURCES ../third_party/jsoncpp/jsoncpp.cpp)
|
||||
endif()
|
||||
|
||||
# Shared sources
|
||||
set (SOURCES
|
||||
${JSONCPP_SOURCES}
|
||||
|
||||
test_runner.cpp
|
||||
IXTest.cpp
|
||||
../third_party/msgpack11/msgpack11.cpp
|
||||
|
||||
IXSocketTest.cpp
|
||||
IXSocketConnectTest.cpp
|
||||
set (TEST_TARGET_NAMES
|
||||
IXSocketTest
|
||||
IXSocketConnectTest
|
||||
# IXWebSocketLeakTest.cpp # commented until we have a fix for #224
|
||||
IXWebSocketServerTest.cpp
|
||||
IXWebSocketTestConnectionDisconnection.cpp
|
||||
IXUrlParserTest.cpp
|
||||
IXWebSocketServerTest.cpp
|
||||
IXHttpClientTest.cpp
|
||||
IXHttpServerTest.cpp
|
||||
IXUnityBuildsTest.cpp
|
||||
IXHttpTest.cpp
|
||||
IXDNSLookupTest.cpp
|
||||
IXWebSocketSubProtocolTest.cpp
|
||||
IXSentryClientTest.cpp
|
||||
IXWebSocketChatTest.cpp
|
||||
IXWebSocketBroadcastTest.cpp
|
||||
IXWebSocketPerMessageDeflateCompressorTest.cpp
|
||||
IXStreamSqlTest.cpp
|
||||
IXWebSocketServerTest
|
||||
IXWebSocketTestConnectionDisconnection
|
||||
IXUrlParserTest
|
||||
IXHttpClientTest
|
||||
IXHttpServerTest
|
||||
IXUnityBuildsTest
|
||||
IXHttpTest
|
||||
IXDNSLookupTest
|
||||
IXWebSocketSubProtocolTest
|
||||
IXSentryClientTest
|
||||
IXWebSocketChatTest
|
||||
IXWebSocketBroadcastTest
|
||||
IXWebSocketPerMessageDeflateCompressorTest
|
||||
IXStreamSqlTest
|
||||
)
|
||||
|
||||
# Some unittest don't work on windows yet
|
||||
# Windows without TLS does not have hmac yet
|
||||
if (UNIX)
|
||||
list(APPEND SOURCES
|
||||
IXWebSocketCloseTest.cpp
|
||||
IXCobraChatTest.cpp
|
||||
IXCobraMetricsPublisherTest.cpp
|
||||
IXCobraToSentryBotTest.cpp
|
||||
IXCobraToStatsdBotTest.cpp
|
||||
IXCobraToStdoutBotTest.cpp
|
||||
list(APPEND TEST_TARGET_NAMES
|
||||
IXWebSocketCloseTest
|
||||
IXCobraChatTest
|
||||
IXCobraMetricsPublisherTest
|
||||
IXCobraToSentryBotTest
|
||||
IXCobraToStatsdBotTest
|
||||
IXCobraToStdoutBotTest
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -71,19 +49,9 @@ endif()
|
||||
|
||||
# Disable tests for now that are failing or not reliable
|
||||
|
||||
add_executable(ixwebsocket_unittest ${SOURCES})
|
||||
|
||||
if (MAC)
|
||||
add_sanitizers(ixwebsocket_unittest)
|
||||
endif()
|
||||
|
||||
if (APPLE AND USE_TLS)
|
||||
target_link_libraries(ixwebsocket_unittest "-framework foundation" "-framework security")
|
||||
endif()
|
||||
|
||||
if (JSONCPP_FOUND)
|
||||
target_include_directories(ixwebsocket_unittest PUBLIC ${JSONCPP_INCLUDE_DIRS})
|
||||
target_link_libraries(ixwebsocket_unittest ${JSONCPP_LIBRARIES})
|
||||
find_package(JsonCpp)
|
||||
if (NOT JSONCPP_FOUND)
|
||||
set(JSONCPP_SOURCES ../third_party/jsoncpp/jsoncpp.cpp)
|
||||
endif()
|
||||
|
||||
if (USE_PYTHON)
|
||||
@ -97,19 +65,67 @@ if (USE_PYTHON)
|
||||
message("Python_LIBRARIES:${Python_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
# library with the most dependencies come first
|
||||
target_link_libraries(ixwebsocket_unittest ixbots)
|
||||
target_link_libraries(ixwebsocket_unittest ixsnake)
|
||||
target_link_libraries(ixwebsocket_unittest ixcobra)
|
||||
target_link_libraries(ixwebsocket_unittest ixsentry)
|
||||
target_link_libraries(ixwebsocket_unittest ixredis)
|
||||
target_link_libraries(ixwebsocket_unittest ixwebsocket)
|
||||
target_link_libraries(ixwebsocket_unittest ixcrypto)
|
||||
target_link_libraries(ixwebsocket_unittest ixcore)
|
||||
add_library(ixwebsocket_test)
|
||||
target_sources(ixwebsocket_test PRIVATE
|
||||
${JSONCPP_SOURCES}
|
||||
test_runner.cpp
|
||||
IXTest.cpp
|
||||
../third_party/msgpack11/msgpack11.cpp
|
||||
)
|
||||
target_compile_definitions(ixwebsocket_test PRIVATE ${TEST_PROGRAMS_DEFINITIONS})
|
||||
target_include_directories(ixwebsocket_test PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
||||
../third_party
|
||||
)
|
||||
target_link_libraries(ixwebsocket_test ixsnake)
|
||||
target_link_libraries(ixwebsocket_test ixcobra)
|
||||
target_link_libraries(ixwebsocket_test ixwebsocket)
|
||||
target_link_libraries(ixwebsocket_test spdlog)
|
||||
|
||||
target_link_libraries(ixwebsocket_unittest spdlog)
|
||||
if (USE_PYTHON)
|
||||
target_link_libraries(ixwebsocket_unittest ${Python_LIBRARIES})
|
||||
endif()
|
||||
foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
|
||||
add_executable(${TEST_TARGET_NAME}
|
||||
${TEST_TARGET_NAME}.cpp
|
||||
)
|
||||
|
||||
install(TARGETS ixwebsocket_unittest DESTINATION bin)
|
||||
target_include_directories(${TEST_TARGET_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
||||
../third_party
|
||||
../third_party/msgpack11
|
||||
)
|
||||
|
||||
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE SPDLOG_COMPILED_LIB=1)
|
||||
|
||||
if (NOT JSONCPP_FOUND)
|
||||
target_include_directories(${TEST_TARGET_NAME} PRIVATE ../third_party/jsoncpp)
|
||||
endif()
|
||||
|
||||
if (APPLE AND USE_TLS)
|
||||
target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security")
|
||||
endif()
|
||||
|
||||
if (JSONCPP_FOUND)
|
||||
target_include_directories(${TEST_TARGET_NAME} PRIVATE ${JSONCPP_INCLUDE_DIRS})
|
||||
target_link_libraries(${TEST_TARGET_NAME} ${JSONCPP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# library with the most dependencies come first
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixbots)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixsnake)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixcobra)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixsentry)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixredis)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket_test)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixcrypto)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ixcore)
|
||||
|
||||
target_link_libraries(${TEST_TARGET_NAME} spdlog)
|
||||
if (USE_PYTHON)
|
||||
target_link_libraries(${TEST_TARGET_NAME} ${Python_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_test(NAME ${TEST_TARGET_NAME}
|
||||
COMMAND ${TEST_TARGET_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
endforeach()
|
||||
|
Reference in New Issue
Block a user