Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/TestSuite.cmake
# Allow to easily build test suites | # Allow to easily build test suites | ||||
# Define a new target property to hold the list of tests associated with a test | # Define a new target property to hold the list of tests associated with a test | ||||
# suite. This property is named UNIT_TESTS to avoid confusion with the directory | # suite. This property is named UNIT_TESTS to avoid confusion with the directory | ||||
# level property TESTS. | # level property TESTS. | ||||
define_property(TARGET | define_property(TARGET | ||||
PROPERTY UNIT_TESTS | PROPERTY UNIT_TESTS | ||||
BRIEF_DOCS "List of tests" | BRIEF_DOCS "List of tests" | ||||
FULL_DOCS "A list of the tests associated with a test suite" | FULL_DOCS "A list of the tests associated with a test suite" | ||||
) | ) | ||||
macro(get_target_from_suite SUITE TARGET) | macro(get_target_from_suite SUITE TARGET) | ||||
set(${TARGET} "check-${SUITE}") | set(${TARGET} "check-${SUITE}") | ||||
endmacro() | endmacro() | ||||
include(Coverage) | |||||
function(create_test_suite_with_parent_targets NAME) | function(create_test_suite_with_parent_targets NAME) | ||||
get_target_from_suite(${NAME} TARGET) | get_target_from_suite(${NAME} TARGET) | ||||
add_custom_target(${TARGET} | add_custom_target(${TARGET} | ||||
COMMENT "Running ${NAME} test suite" | COMMENT "Running ${NAME} test suite" | ||||
COMMAND cmake -E echo "PASSED: ${NAME} test suite" | COMMAND cmake -E echo "PASSED: ${NAME} test suite" | ||||
) | ) | ||||
foreach(PARENT_TARGET ${ARGN}) | foreach(PARENT_TARGET ${ARGN}) | ||||
if(TARGET ${PARENT_TARGET}) | if(TARGET ${PARENT_TARGET}) | ||||
add_dependencies(${PARENT_TARGET} ${TARGET}) | add_dependencies(${PARENT_TARGET} ${TARGET}) | ||||
endif() | endif() | ||||
endforeach() | endforeach() | ||||
add_custom_target_coverage(${TARGET}) | |||||
endfunction() | endfunction() | ||||
macro(create_test_suite NAME) | macro(create_test_suite NAME) | ||||
create_test_suite_with_parent_targets(${NAME} check-all check-extended) | create_test_suite_with_parent_targets(${NAME} check-all check-extended) | ||||
endmacro() | endmacro() | ||||
set(TEST_RUNNER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/../templates/TestRunner.cmake.in") | set(TEST_RUNNER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/../templates/TestRunner.cmake.in") | ||||
function(add_test_runner SUITE NAME EXECUTABLE) | function(add_test_runner SUITE NAME EXECUTABLE) | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |