如何使用 CTEST_CUSTOM_PRE_TEST?
我搜索了所有文档,但似乎找不到使用 CTEST_CUSTOM_PRE_TEST
的单个示例。
基本上我需要在测试运行之前在服务器上启动并运行一些命令。所以我需要添加一些预测试步骤。 CTEST_CUSTOM_PRE_TEST
的语法是什么?
CTEST_CUSTOM_PRE_TEST( ??? what to put here ??? )
ADD_TEST(MyTest MyTestCommand)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CTEST_CUSTOM_PRE_TEST 是在运行 ctest 仪表板的上下文中使用的变量。它应该直接在 ctest -S 脚本本身中设置,或者在构建树顶部的 CTestCustom.cmake 文件中设置。
在任一文件中,示例值可能是:
它应该是单个命令行,格式正确,适合在您所在的系统上运行。它在所有测试运行之前在 ctest_test 调用期间运行一次。同样,还有一个 CTEST_CUSTOM_POST_TEST 变量,它也应该是单个命令行,但在所有测试完成后运行。
使用空格、引号和反斜杠引用和转义参数可能具有挑战性……但也许您也不需要这样做。
我不知道可以向您指出的真实世界示例,但我可以阅读 ctest 源代码...;-)
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:
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... ;-)
将
set(CTEST_CUSTOM_PRE_TEST ..
) 放入文件中,该文件在 cmake 执行期间会复制到${CMAKE_BINARY_DIR}/CTestCustom.cmake
。有关详细信息,请参阅 https://stackoverflow.com/a/37748933/1017348。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.在无头 Linux 上的 OpenSCAD 中,我们尝试在
ctest
运行之前启动虚拟帧缓冲区。但我们不使用PRE_TEST
。在cmake
运行期间,我们在构建目录中构建自己的CTestCustom.cmake
。 (我们确实使用了POST_TEST
,但有一些最新版本的 CMake 其中POST_TEST
被破坏了)。您可以在此处找到代码 https://github.com/openscad/openscad/blob/大师/测试
In OpenSCAD on headless Linux we attempt to startup a virtual framebuffer before
ctest
runs. We don't usePRE_TEST
though. We build our ownCTestCustom.cmake
in the build directory during thecmake
run. (We do usePOST_TEST
, but there were a few recent versions of CMake wherePOST_TEST
was broken).You can find the code here https://github.com/openscad/openscad/blob/master/tests