I have some source code that is compiled using CMake, with unit tests that are added to CTest via the CMake directive add_test(). I want the list of executables (absolute/relative path) that are used within this test suite.
Since tests are added as follows:
add_test(NAME ${A} COMMAND ${execA})
add_test(NAME ${B} COMMAND ${execB})
add_test(NAME ${C} COMMAND ${execA} ${addOptions})
there are only two distinct executables (${execA}, ${execB}) for three tests (${A}, ${B}, and ${C}).
I am totally fine having duplicates and ignoring options or having options.
So, the ideal output would be the following (but I certainly can do some parsing manually if needed):
src/folder1/test/testThisFunction
src/folder2/test/testThatFunction
src/folder1/test/testThisFunction -WithThisFlag
The closest I was able to get was with:
ctest -N,--show-only
which does not run the tests, but simply shows them:
Start 1: testA
1/3 Test #1: testA ....................... Passed 0.01 sec
Start 2: testB
2/3 Test #2: testB ....................... Passed 0.01 sec
Start 3: testC
3/3 Test #3: testC ........................ Passed 0.01 sec
Unfortunately, this output does not contain the information about the path to the executable.
In this example above, it is assumed that
${execA} = testThisFunction
${execB} = testThatFunction
where testThisFunction and testThatFunction are CMake targets (unit tests) and
${A} = "testA"
${B} = "testB"
${C} = "testC"
${addOptions} = "-WithThisFlag"
store names of the tests and options, respectively.
While I have the access to CMakeLists.txt, I strongly prefer to do this solely on ctest level after CMake configuring and subsequent compilation are already completed (thus, not generating list of executables using CMake commands in CMakeLists.txt).
If this is relevant, I am using CTest 3.10.2, but open to upgrade.