【发布时间】:2017-12-29 00:34:23
【问题描述】:
我有 ctest 设置,并且可以很好地处理我为该项目构建的所有可执行文件。问题是我想用系统命令添加一些测试,它与解决方案中的程序无关,我无法通过 ctest 运行它。
我添加了一个简单的测试如下,它只是运行命令echo:
add_test(NAME toto_test COMMAND echo bla bla bla)
然后当我运行 ctest 时,我得到了错误
Start 1: toto_test
Could not find executable echo
Looked in the following places:
echo
echo.exe
Release/echo
Release/echo.exe
Release/echo
Release/echo.exe
Unable to find executable: echo
1/10 Test #1: toto_test ........................***Not Run 0.00 sec
The following tests FAILED:
1 - toto_test (Not Run)
Errors while running CTest
当我使用详细选项运行 ctest 时,我得到了
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
Start 1: toto_test
Could not find executable echo
Looked in the following places:
echo
echo.exe
Release/echo
Release/echo.exe
Release/echo
Release/echo.exe
1: Test command: "bla" "bla" "bla"
Unable to find executable: echo
1/1 Test #1: toto_test ........................***Not Run 0.00 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.02 sec
The following tests FAILED:
1 - toto_test (Not Run)
Errors while running CTest
有人可以帮忙吗。 非常感谢
【问题讨论】:
-
你应该试试
FIND_PROGRAM()或${CMAKE_COMMAND} -E echo会更便携