Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/TestSuite.cmake
Show All 33 Lines | define_property(TARGET | ||||
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() | ||||
macro(get_pool_from_suite SUITE POOL) | |||||
set(${POOL} "${SUITE}-pool") | |||||
endmacro() | |||||
include(Coverage) | 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}) | 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() | ||||
# After this call, all the tests added to the suite will also be added to the | |||||
# pool. Works only with the Ninja generators. | |||||
function(test_suite_create_pool SUITE JOBS) | |||||
# Create a pool for the test suite | |||||
get_pool_from_suite(${SUITE} POOL) | |||||
set_property(GLOBAL APPEND PROPERTY JOB_POOLS ${POOL}=${JOBS}) | |||||
endfunction() | |||||
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) | ||||
cmake_parse_arguments(ARG "JUNIT" "" "" ${ARGN}) | cmake_parse_arguments(ARG "JUNIT" "" "" ${ARGN}) | ||||
get_target_from_suite(${SUITE} SUITE_TARGET) | get_target_from_suite(${SUITE} SUITE_TARGET) | ||||
set(TARGET "${SUITE_TARGET}-${NAME}") | set(TARGET "${SUITE_TARGET}-${NAME}") | ||||
# If there is a pool associated to the test suite, then add the test to the | |||||
# pool. | |||||
get_property(JOB_POOLS GLOBAL PROPERTY JOB_POOLS) | |||||
get_pool_from_suite(${SUITE} POOL) | |||||
if(JOB_POOLS MATCHES ${POOL}) | |||||
set(JOB_POOL_ARG JOB_POOL ${POOL}) | |||||
endif() | |||||
add_test_custom_target(${TARGET} | add_test_custom_target(${TARGET} | ||||
TEST_COMMAND | TEST_COMMAND | ||||
"${CMAKE_SOURCE_DIR}/cmake/utils/test_wrapper.sh" | "${CMAKE_SOURCE_DIR}/cmake/utils/test_wrapper.sh" | ||||
"${SUITE}-${NAME}.log" | "${SUITE}-${NAME}.log" | ||||
${CMAKE_CROSSCOMPILING_EMULATOR} "$<TARGET_FILE:${EXECUTABLE}>" ${ARG_UNPARSED_ARGUMENTS} | ${CMAKE_CROSSCOMPILING_EMULATOR} "$<TARGET_FILE:${EXECUTABLE}>" ${ARG_UNPARSED_ARGUMENTS} | ||||
CUSTOM_TARGET_ARGS | CUSTOM_TARGET_ARGS | ||||
COMMENT "${SUITE}: testing ${NAME}" | COMMENT "${SUITE}: testing ${NAME}" | ||||
DEPENDS ${EXECUTABLE} | DEPENDS ${EXECUTABLE} | ||||
VERBATIM | VERBATIM | ||||
${JOB_POOL_ARG} | |||||
) | ) | ||||
add_dependencies(${SUITE_TARGET} ${TARGET}) | add_dependencies(${SUITE_TARGET} ${TARGET}) | ||||
if(ENABLE_JUNIT_REPORT AND ARG_JUNIT) | if(ENABLE_JUNIT_REPORT AND ARG_JUNIT) | ||||
add_custom_command(TARGET ${TARGET} POST_BUILD | add_custom_command(TARGET ${TARGET} POST_BUILD | ||||
COMMENT "Processing junit report for test ${NAME} from suite ${SUITE}" | COMMENT "Processing junit report for test ${NAME} from suite ${SUITE}" | ||||
COMMAND_EXPAND_LISTS | COMMAND_EXPAND_LISTS | ||||
COMMAND | COMMAND | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |