Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use CTEST_CUSTOM_PRE_TEST?

Tags:

cmake

ctest

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)

like image 541
ytk Avatar asked Dec 09 '10 13:12

ytk


3 Answers

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... ;-)

like image 90
DLRdave Avatar answered Nov 07 '22 06:11

DLRdave


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.

like image 34
Joachim W Avatar answered Nov 07 '22 08:11

Joachim W


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

like image 1
don bright Avatar answered Nov 07 '22 08:11

don bright