我发现泛型ctest
命令没有提供有关测试的大量信息,所以我想添加ctest --output-on-failure
但不要让用户担心标志。我希望他们只需要cmake
,make
项目并运行ctest,它应该使用 --output-on-failure
标志运行ctest 。是否可以在CMakeLists.txt中执行此操作?
修改
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(TEST TestName PROPERTY ENVIRONMENT "CTEST_OUTPUT_ON_FAILURE=1")
4/13 Test #4: TEST_SSSP ........................***Failed Required regular expression not found.Regex=[CORRECT
] 0.00 sec
set_property
中的标记无效。
答案 0 :(得分:13)
在CMake 3.17 release notes中,有一个新变量CMAKE_CTEST_ARGUMENTS,您可以将其设置为将任何命令行参数(包括--output-on-failure
)传递给CTest。在您的特定情况下,您现在可以简单地将其添加到CMakeLists.txt:
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
答案 1 :(得分:3)
我按照make check
每个解决方案CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)
add_custom_target(check ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1
${CMAKE_CTEST_COMMAND} -C $<CONFIG> --verbose
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})