I am discovering gtest tests using gtest_discover_tests(…) I then want to set certain properties and labels based on the test names.
(I have done this before several years ago so I know it’s possible I just don’t remember the details and no longer have access to that project.)
I seem to recall this could be made using a file named CTestCustom.cmake
– I have tried playing around with it and for example if I add set(CTEST_CUSTOM_POST_TEST "echo After the test")
in it that is applied and printed.
However how can I use it to iterate over the discovered tests and do operations on them? How do I get hold of the test list for example? And is it even the right file?
gtest_discover_tests
is documented to:
TEST_LIST var
Make the list of tests available in the variable var, rather than the default
<target>_TESTS. This can be useful when the same test executable is being used
in multiple calls to gtest_discover_tests(). Note that this variable is only
available in CTest.
However I don’t seem to have access to that neither in my main CMakeLists.txt or in CTestCustom.cmake.