Testing with CTest.

This commit is contained in:
Vincent Richard 2013-03-11 11:29:16 +01:00
parent 32a80f6c1e
commit c2e16ab09f
2 changed files with 46 additions and 6 deletions

4
.gitignore vendored
View File

@ -28,6 +28,10 @@ doc/html/*
/COPYING.txt
/build/
# CTest-generated files
/CTestTestfile.cmake
/Testing/
# Mac
._DS_Store

View File

@ -197,21 +197,57 @@ 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(
${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(
"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(
"run-tests"
${VMIME_LIBRARY_NAME}