3

Under cmake, the following commands in a CMakeList.txt

enable_testing()
add_test(<test_name> <test_command>) 

suffice to create a test that can be executed through the shell command ctest.

Unfortunately, the cmake docs give not the least indication of what constitutes a valid test executable (<test_command>). Usually, test executables are generated using a framework like google-test. It's a bit involved, but there are good examples in the web that show how to make tests under google-test under cmake.

Now I want to extend my use of cmake/ctest to functional test scripts that need not to be compiled, and therefore cannot be run under google-test. Thence my question: what constitutes a valid hand-written test executable to be directly activated through add_test:

  • Shall my test executable generate output? Shall it write to stdout or stderr?
  • Shall my test executable return certain values to indicate success or failure?
  • Or where in the cmake docs can I find the answer?
4

1 回答 1

3

如果测试通过,您的可执行文件应返回零,否则返回非零。输出被忽略。的文档add_test没有提到这一点。

于 2015-10-18T20:33:11.003 回答