Reputation: 321
I've searched all the docs but can't seem to find a single example of using CTEST_CUSTOM_PRE_TEST
.
Basically I need to start and run some commands on the server before the test runs. So I need to add a few pre-test steps. What's the syntax of CTEST_CUSTOM_PRE_TEST
?
CTEST_CUSTOM_PRE_TEST( ??? what to put here ??? )
ADD_TEST(MyTest MyTestCommand)
Upvotes: 9
Views: 3827
Reputation: 1211
In OpenSCAD on headless Linux we attempt to startup a virtual framebuffer before ctest
runs. We don't use PRE_TEST
though. We build our own CTestCustom.cmake
in the build directory during the cmake
run. (We do use POST_TEST
, but there were a few recent versions of CMake where POST_TEST
was broken).
You can find the code here https://github.com/openscad/openscad/blob/master/tests
Upvotes: 1
Reputation: 8167
Place set(CTEST_CUSTOM_PRE_TEST ..
in a file which during cmake execution is copied to ${CMAKE_BINARY_DIR}/CTestCustom.cmake
. For details, see https://stackoverflow.com/a/37748933/1017348.
Upvotes: 2
Reputation: 14240
CTEST_CUSTOM_PRE_TEST is a variable used in the context of running a ctest dashboard. It should either be set directly in the ctest -S script itself, or in a CTestCustom.cmake file at the top of your build tree.
In either file, an example value might be:
set(CTEST_CUSTOM_PRE_TEST "perl prepareForTesting.pl -with-this -and-that")
It should be a single command line, properly formatted for running on the system you're on. It runs once during a ctest_test call, before all the tests run. Similarly, there is also a CTEST_CUSTOM_POST_TEST variable, that should also be a single command line, but runs after all the tests are done.
Quoting and escaping args with spaces, quotes and backslashes may be challenging ... but maybe you won't need that, either.
I do not know of a real world example of this that I can point you to, but I can read the ctest source code... ;-)
Upvotes: 8