Register unit tests with CMake

Use add_tests() to register the test binaries with CMake
so they can be executed with 'make test'/CTest.

MD-19678 #time 10m
This commit is contained in:
Robert Knight 2013-08-29 15:17:58 +01:00
parent 39b8ada727
commit 5cd4484f8b
2 changed files with 14 additions and 23 deletions

View file

@ -1,6 +1,7 @@
project(updater)
cmake_minimum_required(VERSION 2.6)
enable_testing()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
# If the SIGN_UPDATER option is enabled, the updater.exe

View file

@ -30,27 +30,17 @@ foreach(TEST_FILE ${TEST_FILES})
endforeach()
# Add unit test binaries
add_executable(TestUpdateScript
TestUpdateScript.cpp
)
target_link_libraries(TestUpdateScript
updatershared
)
add_executable(TestUpdaterOptions
TestUpdaterOptions.cpp
)
target_link_libraries(TestUpdaterOptions
updatershared
)
add_executable(TestFileUtils
TestFileUtils.cpp
)
target_link_libraries(TestFileUtils
updatershared
)
if (APPLE)
set_target_properties(TestUpdateScript PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa")
set_target_properties(TestUpdaterOptions PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa")
endif()
macro(ADD_UPDATER_TEST CLASS)
set(TEST_TARGET ${CLASS})
add_executable(${TEST_TARGET} ${CLASS}.cpp)
target_link_libraries(${TEST_TARGET} updatershared)
add_test(${TEST_TARGET} ${TEST_TARGET})
if (APPLE)
set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa")
endif()
endmacro()
add_updater_test(TestUpdateScript)
add_updater_test(TestUpdaterOptions)
add_updater_test(TestFileUtils)