Testing with CTest.
This commit is contained in:
parent
32a80f6c1e
commit
c2e16ab09f
4
.gitignore
vendored
4
.gitignore
vendored
@ -28,6 +28,10 @@ doc/html/*
|
||||
/COPYING.txt
|
||||
/build/
|
||||
|
||||
# CTest-generated files
|
||||
/CTestTestfile.cmake
|
||||
/Testing/
|
||||
|
||||
# Mac
|
||||
._DS_Store
|
||||
|
||||
|
@ -197,20 +197,56 @@ OPTION(
|
||||
|
||||
IF(VMIME_BUILD_TESTS)
|
||||
|
||||
ENABLE_TESTING()
|
||||
|
||||
INCLUDE(cmake/FindCppUnit.cmake)
|
||||
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||
|
||||
FILE(
|
||||
GLOB_RECURSE
|
||||
VMIME_TESTS_SRC_FILES
|
||||
tests/*Test.cpp tests/testRunner.cpp tests/testUtils.cpp
|
||||
${CMAKE_SOURCE_DIR}/tests/*Test.cpp
|
||||
)
|
||||
|
||||
# Build one file for each test
|
||||
FOREACH(VMIME_TEST_SRC_FILE ${VMIME_TESTS_SRC_FILES})
|
||||
|
||||
# "/path/to/vmime/tests/module/testFile.cpp" --> "module_testFile"
|
||||
GET_FILENAME_COMPONENT(VMIME_TEST_SRC_PATH "${VMIME_TEST_SRC_FILE}" PATH)
|
||||
STRING(REPLACE "${CMAKE_SOURCE_DIR}" "" VMIME_TEST_SRC_PATH "${VMIME_TEST_SRC_PATH}")
|
||||
GET_FILENAME_COMPONENT(VMIME_TEST_NAME "${VMIME_TEST_SRC_FILE}" NAME_WE)
|
||||
SET(VMIME_TEST_NAME "${VMIME_TEST_SRC_PATH}/${VMIME_TEST_NAME}")
|
||||
STRING(REPLACE "/" "_" VMIME_TEST_NAME "${VMIME_TEST_NAME}")
|
||||
STRING(REPLACE "_tests_" "" VMIME_TEST_NAME "${VMIME_TEST_NAME}")
|
||||
|
||||
ADD_EXECUTABLE(
|
||||
"run-tests"
|
||||
${VMIME_TESTS_SRC_FILES}
|
||||
${VMIME_TEST_NAME}
|
||||
${VMIME_TEST_SRC_FILE} ${CMAKE_SOURCE_DIR}/tests/testRunner.cpp ${CMAKE_SOURCE_DIR}/tests/testUtils.cpp
|
||||
)
|
||||
|
||||
INCLUDE(cmake/FindCppUnit.cmake)
|
||||
TARGET_LINK_LIBRARIES(
|
||||
${VMIME_TEST_NAME}
|
||||
${VMIME_LIBRARY_NAME}
|
||||
${CPPUNIT_LIBRARY}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||
ADD_DEPENDENCIES(
|
||||
${VMIME_TEST_NAME}
|
||||
${VMIME_LIBRARY_NAME}
|
||||
)
|
||||
|
||||
ADD_TEST(
|
||||
${VMIME_TEST_NAME}
|
||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${VMIME_TEST_NAME}
|
||||
)
|
||||
|
||||
ENDFOREACH()
|
||||
|
||||
# Build one file for all tests
|
||||
ADD_EXECUTABLE(
|
||||
"run-tests"
|
||||
${VMIME_TESTS_SRC_FILES} ${CMAKE_SOURCE_DIR}/tests/testRunner.cpp ${CMAKE_SOURCE_DIR}/tests/testUtils.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
"run-tests"
|
||||
|
Loading…
Reference in New Issue
Block a user