Permalink
Browse files

Add CTests for all components

  • Loading branch information...
1 parent 9c1c1de commit 975c30faf0d77d8fd85abb6bc73eaedaaf6c6627 @bachp bachp committed Jun 16, 2014
@@ -15,6 +15,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoCrypto PocoNetSSL PocoXML PocoUtil PocoFoundation CppUnit pthread)
@@ -20,6 +20,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoData PocoUtil PocoXML PocoFoundation CppUnit)
@@ -145,17 +145,28 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
+set_tests_properties(${LIBNAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=.") # The SharedLibaryTest has to look for shared libraries in the working directory
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoFoundation CppUnit )
if (NOT ANDROID)
target_link_libraries( ${TESTUNIT} pthread)
endif ()
+# The test is run in the build directory. So the test data is copied there too
+add_custom_command(TARGET ${TESTUNIT} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
+
add_executable( TestApp src/TestApp.cpp )
+# The test is run in the build directory. So the TestApp is built there too because it is used by the tests
+set_target_properties( TestApp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
#set_target_properties( TestApp PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( TestApp PocoFoundation )
-add_library( TestLibrary SHARED src/TestApp.cpp )
+add_library( TestLibrary SHARED src/TestLibrary.cpp )
+set_target_properties( TestLibrary PROPERTIES PREFIX "") # The test requires the library named TestLibrary. By default it is prefixed with lib.
+# The test is run in the build directory. So the TestLibrary is built there too because it is used by the tests
+set_target_properties( TestLibrary PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
#set_target_properties( TestLibrary PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( TestLibrary PocoFoundation )
@@ -15,6 +15,11 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoJSON PocoFoundation CppUnit )
+# The test is run in the build directory. So the test data is copied there too
+add_custom_command(TARGET ${TESTUNIT} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
+
@@ -15,6 +15,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoMongoDB PocoFoundation CppUnit )
@@ -68,6 +68,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoNet PocoUtil PocoXML PocoFoundation CppUnit)
@@ -20,6 +20,14 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML PocoFoundation CppUnit)
+# The test is run in the build directory. So the test data is copied there too
+add_custom_command(TARGET ${TESTUNIT} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/any.pem ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_CURRENT_BINARY_DIR}/${TESTUNIT}.xml
+ )
+
@@ -15,6 +15,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoPDF PocoFoundation CppUnit )
@@ -34,5 +34,6 @@ src/WindowsTestSuite.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoUtil PocoJSON PocoXML PocoFoundation CppUnit)
@@ -31,6 +31,7 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoXML PocoFoundation CppUnit)
@@ -15,6 +15,11 @@ src/WinDriver.cpp
set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} )
+add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoZip PocoNet PocoFoundation CppUnit )
+# The test is run in the build directory. So the test data is copied there too
+add_custom_command(TARGET ${TESTUNIT} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
+

0 comments on commit 975c30f

Please sign in to comment.