Pass CTest test description in custom property or environment

Prior to this change, each test would have, as label, it's description.
This leads to many labels, which are normally reserved for grouping
tests. Move the description into a custom property instead.

Since we rely on the JSON output for the generation of HTML reports, we
need to also extract the description from the generated JSON. However,
custom properties are only logged starting from cmake 3.30. For
back-wards compatibility, write an additional, separate environment
variable TEST_DESCRIPTION from which the description can be read as a
fallback.

For the add_timed_physim_test(), this has been already done in a parent
commit.
This commit is contained in:
Robert Schmidt
2025-09-12 14:54:49 +02:00
parent e5139b6f0f
commit eb9e4ef9ba
2 changed files with 26 additions and 3 deletions
+8 -2
View File
@@ -1,3 +1,5 @@
define_property(TEST PROPERTY TEST_DESCRIPTION BRIEF_DOCS "A human-readable description of this test")
# Define a macro to add tests for different physical simulators
macro(add_physim_test test_name test_description test_exec)
# catch all the arguments past the last expected arqument and store them in the options_list
@@ -11,8 +13,12 @@ macro(add_physim_test test_name test_description test_exec)
COMMAND_EXPAND_LISTS
)
set_tests_properties(${test_name} PROPERTIES
LABELS "${test_exec}: ${test_description};${test_exec}"
ENVIRONMENT "LD_LIBRARY_PATH=."
LABELS "${test_exec}"
TEST_DESCRIPTION "${test_description}"
# pass test description also through environment variable: for cmake < 3.30,
# in JSON export, we cannot recover the description otherwise
# see also https://gitlab.kitware.com/cmake/cmake/-/issues/21490
ENVIRONMENT "LD_LIBRARY_PATH=.;TEST_DESCRIPTION=${test_description}"
)
add_dependencies(tests ${test_exec})
endmacro()