1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(cmake): Add unit_test build

This commit is contained in:
Diadlo 2017-01-30 23:39:52 +03:00
parent 5873a04856
commit 0d56fb946d
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 36 additions and 19 deletions

View File

@ -33,7 +33,6 @@ set(CMAKE_OSX_SYSROOT
${CMAKE_OSX_SYSROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}.sdk) ${CMAKE_OSX_SYSROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}.sdk)
project(qtox) project(qtox)
include(CTest)
# Instruct CMake to run moc automatically when needed. # Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -498,22 +497,5 @@ target_link_libraries(${PROJECT_NAME}
${PROJECT_NAME}_static ${PROJECT_NAME}_static
${ALL_LIBRARIES}) ${ALL_LIBRARIES})
################################################################################ include(Testing)
#
# :: Tests
#
################################################################################
function(auto_test subsystem module)
add_executable(${module}_test
test/${subsystem}/${module}_test.cpp)
target_link_libraries(${module}_test
${PROJECT_NAME}_static
${ALL_LIBRARIES}
Qt5::Test)
add_test(
NAME test_${module}
COMMAND ${module}_test)
endfunction()
include(Installation) include(Installation)

22
cmake/Testing.cmake Normal file
View File

@ -0,0 +1,22 @@
################################################################################
#
# :: Testing
#
################################################################################
include(CTest)
enable_testing()
function(auto_test subsystem module)
add_executable(test_${module}
test/common.h
test/${subsystem}/${module}_test.cpp)
target_link_libraries(test_${module}
${PROJECT_NAME}_static
${ALL_LIBRARIES}
Qt5::Test)
add_test(
NAME test_${module}
COMMAND test_${module})
endfunction()

13
test/common.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef _TEST_COMMON_H_
#define _TEST_COMMON_H_
#define DEFTESTCASE(NAME) \
TCase *tc_##NAME = tcase_create(#NAME); \
tcase_add_test(tc_##NAME, NAME##Test); \
suite_add_tcase(s, tc_##NAME);
#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \
DEFTESTCASE(NAME) \
tcase_set_timeout(tc_##NAME, TIMEOUT);
#endif // _TEST_COMMON_H_