8

我搜索了所有文档,但似乎找不到使用 CTEST_CUSTOM_PRE_TEST 的单个示例。

基本上我需要在测试运行之前在服务器上启动并运行一些命令。所以我需要添加一些预测试步骤。CTEST_CUSTOM_PRE_TEST 的语法是什么?

CTEST_CUSTOM_PRE_TEST( ??? 在这里放什么??? ) ADD_TEST(MyTest MyTestCommand)

4

3 回答 3

7

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

于 2011-02-11T20:46:54.963 回答
2

放置set(CTEST_CUSTOM_PRE_TEST ..在一个文件中,该文件在 cmake 执行期间被复制到${CMAKE_BINARY_DIR}/CTestCustom.cmake. 有关详细信息,请参阅https://stackoverflow.com/a/37748933/1017348

于 2016-06-10T13:03:08.560 回答
1

在无头 linux 上的 OpenSCAD 中,我们尝试在 ctest 运行之前启动虚拟帧缓冲区。我们不使用 PRE_TEST。在“cmake”运行期间,我们在构建目录中构建自己的 CTestCustom.cmake。(我们确实使用 POST_TEST,但最近有几个版本的 cmake POST_TEST 被破坏了)

你可以在这里找到代码https://github.com/openscad/openscad/blob/master/tests

于 2014-08-06T04:20:57.647 回答