Suppose I have a test defined like:
add_test(NAME myCoolTest COMMAND testRunner normalArg)
I’d like to be able to modify myCoolTest
when I call ctest
, by doing something like:
ctest -R myCoolTest -D do-crazy=1
…which would then somehow result in running:
testRunner --do-crazy-option normalArg
I was hoping that some combination of ctest -D <var>:<type>=<value>
and CTestCustom.cmake
might allow me to alter the invoked test command somehow - however, there’s two problems with this approach:
- It seems that I can’t access variables defined via
ctest -D var=value
from withinCTestCustom.cmake
- From within
CTestCustom.cmake
, I don’t know how (or if it’s possible) to modifymyCoolTest
(or any test)
Is there any way to customize test behavior by specifying command flags to ctest?
In theory, I know I could use env variables to modify behavior… however, since I don’t have direct access to testRunner
in my example, I’d have to make a wrapper executable, testRunnerWrapper
, which checks the env and then invokes testRunner
, which I’d like to avoid if I can. Also, I always prefer using command flags over env vars if possible - it feels more explicit and discoverable…