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
|
/COPYING.txt
|
||||||
/build/
|
/build/
|
||||||
|
|
||||||
|
# CTest-generated files
|
||||||
|
/CTestTestfile.cmake
|
||||||
|
/Testing/
|
||||||
|
|
||||||
# Mac
|
# Mac
|
||||||
._DS_Store
|
._DS_Store
|
||||||
|
|
||||||
|
@ -197,21 +197,57 @@ OPTION(
|
|||||||
|
|
||||||
IF(VMIME_BUILD_TESTS)
|
IF(VMIME_BUILD_TESTS)
|
||||||
|
|
||||||
|
ENABLE_TESTING()
|
||||||
|
|
||||||
|
INCLUDE(cmake/FindCppUnit.cmake)
|
||||||
|
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||||
|
|
||||||
FILE(
|
FILE(
|
||||||
GLOB_RECURSE
|
GLOB_RECURSE
|
||||||
VMIME_TESTS_SRC_FILES
|
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(
|
||||||
|
${VMIME_TEST_NAME}
|
||||||
|
${VMIME_TEST_SRC_FILE} ${CMAKE_SOURCE_DIR}/tests/testRunner.cpp ${CMAKE_SOURCE_DIR}/tests/testUtils.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(
|
||||||
|
${VMIME_TEST_NAME}
|
||||||
|
${VMIME_LIBRARY_NAME}
|
||||||
|
${CPPUNIT_LIBRARY}
|
||||||
|
)
|
||||||
|
|
||||||
|
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(
|
ADD_EXECUTABLE(
|
||||||
"run-tests"
|
"run-tests"
|
||||||
${VMIME_TESTS_SRC_FILES}
|
${VMIME_TESTS_SRC_FILES} ${CMAKE_SOURCE_DIR}/tests/testRunner.cpp ${CMAKE_SOURCE_DIR}/tests/testUtils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE(cmake/FindCppUnit.cmake)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
"run-tests"
|
"run-tests"
|
||||||
${VMIME_LIBRARY_NAME}
|
${VMIME_LIBRARY_NAME}
|
||||||
|
Loading…
Reference in New Issue
Block a user