CMake 和 CTest:如何使目标“每晚”实际构建测试
这是一个众所周知的问题,执行 make "test" 不会构建所讨论的测试 这里。正如所建议的,这个问题可以通过人工目标“检查”来部分解决。我想知道当我调用“make Nightly”时如何强制构建测试。
到目前为止我所做的:
add_custom_target(buildtests)
add_custom_target(check COMMAND "ctest")
add_dependencies(check buildtests)
add_dependencies(Nightly buildtests)
add_dependencies(buildtests Test1)
...
add_dependencies(buildtests TestN)
现在“make check”构建并运行测试,但“make Nightly”
- 构建测试
- 将存储库更新为 CTEST_NIGHTLY_START_TIME
- 构建所有其他目标
- 运行(现已过时)测试
It's a well known problem that executing make "test" doesn't build the tests as discussed here. As suggested, the problem can be partly solved with the artificial target "check". I want to know how I can force building of tests when i call "make Nightly".
What I've done so far:
add_custom_target(buildtests)
add_custom_target(check COMMAND "ctest")
add_dependencies(check buildtests)
add_dependencies(Nightly buildtests)
add_dependencies(buildtests Test1)
...
add_dependencies(buildtests TestN)
Now "make check" builds an runs the tests, but "make Nightly"
- builds the tests
- updates the repo to CTEST_NIGHTLY_START_TIME
- builds all other targets
- runs the (now outdated) tests
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的,这实际上是我自己的调用错误:
解决方案是将其更改为
然后调用
You're right, it was actually my own fault for calling:
The solution was to change it to
and then call
如果您查看输出,
它提到了 ALL 参数,“如果指定了 ALL 选项,则表明应将此目标添加到默认构建目标,以便每次都会运行它”。您需要将此参数添加到自定义目标中,并且 Nightly 目标运行 make 来构建默认构建目标中的所有内容。因此,应该执行以下操作,
您的另一个选择是编写自定义 CTest 脚本,它可以让您对项目的构建和测试进行更细粒度的控制。
If you look at the output of,
It mentions the ALL argument, "If the ALL option is specified it indicates that this target should be added to the default build target so that it will be run every time". You would need to add this argument to your custom target, and the Nightly target runs a make to build everything in the default build target. So the following should do it,
Your other option would be to write a custom CTest script, which gives you much finer grained control of the build and testing of your project.