alfC
alfC

Reputation: 16242

Adding a prefix command to all ctest executions

I am following the instructions to use the mutation testing framework Mull and integrating it with CMake

https://mull.readthedocs.io/en/latest/tutorials/CMakeIntegration.html

The last step involves executing the test using the mull-runner. For example:

$ mull-runner-12 test/my_test.exe

I have many tests in my project, and I simply usually run all of them with ctest.

Is there a way to tell ctest, from the command, to add a prefix to all execution commands? (in this case the prefix will be mull-runner-12).

Upvotes: 0

Views: 69

Answers (1)

KamilCuk
KamilCuk

Reputation: 140870

From https://cmake.org/cmake/help/latest/command/add_test.html#command:add_test :

Added in version 3.29: The target's TEST_LAUNCHER, if set, will be used to launch the command:

<launcher> <command>

From https://cmake.org/cmake/help/latest/prop_tgt/TEST_LAUNCHER.html#prop_tgt:TEST_LAUNCHER :

This property is initialized by the value of the CMAKE_TEST_LAUNCHER ...

Do make -DCMAKE_TEST_LAUNCHER=mull-runner-12.


The other way for previous version of cmake was to overwrite cmake commands, like so:

function(add_test NAME name COMMAND command)
   _add_test(${NAME} ${name} ${COMMAND} mull-runner-12 ${command} ${ARGV})
endfunction()

Add such function on top of your CMakeLists.txt or somewhere.

Upvotes: 1

Related Questions