How do you use CTEST_CUSTOM_PRE_TEST?
Asked Answered
D

3

9

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)
Dasyure answered 9/12, 2010 at 13:30 Comment(0)
C
8

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

Criss answered 11/2, 2011 at 20:46 Comment(0)
W
2

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://mcmap.net/q/1315994/-let-cmake-setup-cttest-to-print-header-and-footer-around-the-output-from-single-tests.

Weywadt answered 10/6, 2016 at 13:3 Comment(0)
T
1

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

Tito answered 6/8, 2014 at 4:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.