如何使用 CTEST_CUSTOM_PRE_TEST?

发布于 2024-10-07 00:13:26 字数 266 浏览 5 评论 0原文

我搜索了所有文档,但似乎找不到使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一曲琵琶半遮面シ 2024-10-14 00:13:26

CTEST_CUSTOM_PRE_TEST 是在运行 ctest 仪表板的上下文中使用的变量。它应该直接在 ctest -S 脚本本身中设置,或者在构建树顶部的 CTestCustom.cmake 文件中设置。

在任一文件中,示例值可能是:

set(CTEST_CUSTOM_PRE_TEST "perl prepareForTesting.pl -with-this -and-that")

它应该是单个命令行,格式正确,适合在您所在的系统上运行。它在所有测试运行之前在 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:

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

葬花如无物 2024-10-14 00:13:26

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.

瑾兮 2024-10-14 00:13:26

在无头 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 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文