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) project(updater)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
enable_testing()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
# If the SIGN_UPDATER option is enabled, the updater.exe # If the SIGN_UPDATER option is enabled, the updater.exe

View file

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