本文介绍了将ctest命令替换为“ ctest --failure-output-failure”。永久用于CMakeLists.txt中的特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现通用 ctest 命令没有提供有关测试的太多信息,因此我想添加 ctest --output-失败,但用户不必担心该标志。我希望他们只执行 cmake make 项目并运行ctest,它应该运行ctest with -失败输出标志。

I have found that generic ctest command doesn't give much information about the tests, so I would like to add ctest --output-on-failure but not have the users to worry about the flag. I want them just to cmake, make the project and run ctest and it should run ctest with the --output-on-failure flag. Is it possible to do that in CMakeLists.txt?

编辑:

是否可以在CMakeLists.txt中执行此操作? env CTEST_OUTPUT_ON_FAILURE = 1的输出进行测试

Output of env CTEST_OUTPUT_ON_FAILURE=1 make test

 4/13 Test  #4: TEST_SSSP ........................***Failed  Required regular expression not found.Regex=[CORRECT
]  0.00 sec
Loading Matrix-market coordinate-formatted graph ...
Input graph file /home/muhammad/gunrock/dataset/small/chesapeake.mtx does not exis

set_property的输出(测试TestName属性环境 CTEST_OUTPUT_ON_FAILURE = 1)

 4/13 Test  #4: TEST_SSSP ........................***Failed  Required regular expression not found.Regex=[CORRECT
]  0.00 sec

The set_property 中的标记不起作用。

The flag in set_property is not working.

推荐答案

在CMake 3.17中,其中有一个新变量可以设置为将任何命令行参数传递给CTest,包括-失败时输出。在您的特定情况下,您现在可以简单地将其添加到CMakeLists.txt:

In CMake 3.17 release notes, there's a new variable CMAKE_CTEST_ARGUMENTS that you can set to pass any command-line arguments to CTest, including --output-on-failure. In your specific case, you can now simply add this to your CMakeLists.txt:

list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")

这篇关于将ctest命令替换为“ ctest --failure-output-failure”。永久用于CMakeLists.txt中的特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 16:15