对于 CMakeLists.txt 中的特定项目,将 ctest 命令永久替换为 "ctest --output-on-failure"
Replace ctest command with "ctest --output-on-failure" permanently for a specific project in CMakeLists.txt
我发现通用 ctest
命令没有提供太多关于测试的信息,所以我想添加 ctest --output-on-failure
但不想让用户担心标志。我希望他们只是 cmake
、make
项目和 运行 ctest,它应该 运行 ctest with --output-on-failure
旗帜。是否可以在 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
中的标志无效。
我选择了 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})
在 CMake 3.17 release notes, there's a new variable CMAKE_CTEST_ARGUMENTS 中,您可以设置为将任何命令行参数传递给 CTest,包括 --output-on-failure
。在您的具体情况下,您现在只需将其添加到您的 CMakeLists.txt:
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
我发现通用 ctest
命令没有提供太多关于测试的信息,所以我想添加 ctest --output-on-failure
但不想让用户担心标志。我希望他们只是 cmake
、make
项目和 运行 ctest,它应该 运行 ctest with --output-on-failure
旗帜。是否可以在 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
中的标志无效。
我选择了 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})
在 CMake 3.17 release notes, there's a new variable CMAKE_CTEST_ARGUMENTS 中,您可以设置为将任何命令行参数传递给 CTest,包括 --output-on-failure
。在您的具体情况下,您现在只需将其添加到您的 CMakeLists.txt:
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")