Allow spaces or special characters as a test name or as a test "description"
The documentation for add_test(NAME ...)
states, "The test name may not contain spaces, quotes, or other characters special in CMake syntax." However, the ability to have such special characters would be very useful.
Notably, add_test(...)
without explicit NAME
doesn't make this statement, but it doesn't state that special characters are allowed.
Currently, Catch2's catch_discover_tests()
and CatchAddTests.cmake
currently produce tests whose names are very likely to contain spaces, as it just copies whatever string the user wrote in TEST_CASE("The test case name")
. So the generated CMake code in the TEST_INCLUDE_FILES
list contains add_test(...)
commands which create tests which contain special characters. While this currently appears to work, set_property(TEST ...)
and get_property(TEST ...)
do not work with these test names, but set_tests_properties(...)
kind of works in a broken way (I noticed it appending to LABELS
rather than just overwriting).
I think that it is valuable to be able to describe the test with an arbitrary string. Can we add support for arbitrary test names? If that has implementation concerns, can we provide a DESCRIPTION
test property which is treated as the test name when interacting with ctest
, but require CMake identifiers inside of CMake?