mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Add CMake infrastructure for smoke testing
Necessary CMake changes to implement pre-merge smoke tests running via CI.
This commit is contained in:
@@ -18,6 +18,11 @@ macro(ei_add_test_internal testname testname_with_suffix)
|
||||
set(filename ${testname}.cpp)
|
||||
endif()
|
||||
|
||||
# Add the current target to the list of subtest targets
|
||||
get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST)
|
||||
set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}${targetname}\n")
|
||||
set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
|
||||
|
||||
if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu)
|
||||
if(EIGEN_TEST_HIP)
|
||||
hip_reset_flags()
|
||||
@@ -413,11 +418,13 @@ macro(ei_init_testing)
|
||||
define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
|
||||
define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ")
|
||||
define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
|
||||
define_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
|
||||
|
||||
set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "")
|
||||
set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "")
|
||||
set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "")
|
||||
set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "")
|
||||
set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "")
|
||||
|
||||
define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ")
|
||||
define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ")
|
||||
@@ -708,3 +715,63 @@ macro(ei_split_testsuite num_splits)
|
||||
add_dependencies("${current_target}" "${curr_test}")
|
||||
endforeach()
|
||||
endmacro(ei_split_testsuite num_splits)
|
||||
|
||||
# Defines two custom commands buildsmoketests and smoketests that build and run
|
||||
# a number of tests specified in smoke_test_list.
|
||||
#
|
||||
# Test in smoke_test_list can be either test targets (e.g. packetmath) or
|
||||
# subtests targets (e.g. packetmath_2). If any of the test are not available
|
||||
# in the current configuration they are just skipped.
|
||||
#
|
||||
# Smoke tests are intended to be run before the whole test suite is invoked,
|
||||
# e.g., to smoke test patches.
|
||||
macro(ei_add_smoke_tests smoke_test_list)
|
||||
# Set the build target to build smoketests
|
||||
set(buildtarget "buildsmoketests")
|
||||
add_custom_target("${buildtarget}")
|
||||
|
||||
# We build a regex that matches our smoketests only and will pass it to ctest
|
||||
set(ctest_regex "")
|
||||
|
||||
# Get list of all tests and translate it into a CMake list
|
||||
get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST)
|
||||
string(REGEX REPLACE "\n" " " EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
|
||||
set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
|
||||
separate_arguments(EIGEN_TESTS_LIST)
|
||||
|
||||
# Check if the test in smoke_test_list is a currently valid test target
|
||||
foreach(test IN ITEMS ${smoke_test_list})
|
||||
# Add tests in smoke_test_list to our smoke test target but only if the test
|
||||
# is currently available, i.e., is in EIGEN_SUBTESTS_LIST
|
||||
if ("${test}" IN_LIST EIGEN_TESTS_LIST)
|
||||
add_dependencies("${buildtarget}" "${test}")
|
||||
# In the case of a test we match all subtests
|
||||
set(ctest_regex "${ctest_regex}^${test}_[0-9]+$$|")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Get list of all subtests and translate it into a CMake list
|
||||
get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST)
|
||||
string(REGEX REPLACE "\n" " " EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
|
||||
set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
|
||||
separate_arguments(EIGEN_SUBTESTS_LIST)
|
||||
|
||||
# Check if the test in smoke_test_list is a currently valid subtest target
|
||||
foreach(test IN ITEMS ${smoke_test_list})
|
||||
# Add tests in smoke_test_list to our smoke test target but only if the test
|
||||
# is currently available, i.e., is in EIGEN_SUBTESTS_LIST
|
||||
if ("${test}" IN_LIST EIGEN_SUBTESTS_LIST)
|
||||
add_dependencies("${buildtarget}" "${test}")
|
||||
# In the case of a subtest we match exactly
|
||||
set(ctest_regex "${ctest_regex}^${test}$$|")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Remove trailing '|' in ctest regex
|
||||
string(REGEX REPLACE "\\|$" "" ctest_regex "${ctest_regex}")
|
||||
message(STATUS "${ctest_regex}")
|
||||
# Set the test target to run smoketests
|
||||
set(testtarget "smoketests")
|
||||
add_custom_target("${testtarget}" COMMAND ctest -R '${ctest_regex}' --random-shuffle)
|
||||
add_dependencies("${testtarget}" "${buildtarget}")
|
||||
endmacro(ei_add_smoke_tests)
|
||||
Reference in New Issue
Block a user