ctest

Using REQUIRED_FILES for unit tests in cmake

非 Y 不嫁゛ 提交于 2019-12-24 20:24:19
问题 Very short example trying to use REQUIRED_FILES: $ tree . . ├── CMakeLists.txt └── main.cxx $ cat main.cxx int main() { return 0; } $ cat CMakeLists.txt cmake_minimum_required(VERSION 3.10) add_executable(a.out main.cxx) include(CTest) add_test(NAME a.out COMMAND a.out) set_property(TEST a.out PROPERTY REQUIRED_FILES $<TARGET_FILE:a.out>) One executable, which does nothing, and is a test that just requires itself to exist. $ mkdir build && cd build && cmake .. && ctest -- The C compiler

CMake & CTest : make test doesn't build tests

旧城冷巷雨未停 提交于 2019-12-24 11:09:37
问题 I'm trying CTest in CMake in order to automatically run some of my tests using make test target. The problem is CMake does not "understand" that the test I'm willing to run has to be built since it is part of the project. So I'm looking for a way to explicitly specify this dependency. 回答1: It is arguably a bug in CMake (previously tracked here) that this doesn't work out of the box. A workaround is to do the following: add_test(TestName ExeName) add_custom_target(check COMMAND ${CMAKE_CTEST

CMake and CTest's default “test” command skips a specially named test

怎甘沉沦 提交于 2019-12-22 09:48:59
问题 I'm using CTest with CMake to run some tests. I use the enable_testing() command which provides me with a default command for make test . All of the tests in my subdirectory are accounted for (by doing an add_test command) and make test works great, except one problem. There is a certain test, which I've named skip_test , that I do NOT want being run when I do make test . I would like to add a custom target so I can run make skip_test and it will run that test. I can do this by doing add

How to get CTest results in Hudson / Jenkins

ε祈祈猫儿з 提交于 2019-12-18 10:35:31
问题 I'm using CTest (part of CMake) for my automated tests. How do I get CTest results in the Jenkins dashboard ? Or, phrased differently, how do I get CTest to output in JUnit-like XML ? 回答1: In Jenkins, after the CMake part (probably made through the CMake plugin), add the following batch script, or adapt for builds on Linux : del build_32\JUnitTestResults.xml pushd build_32\Tests "C:\Program Files\CMake 2.8\bin\ctest.exe" -T Test -C RelWithDebInfo --output-on-failure popd verify >nul C:

Producing CTest results in Jenkins (xUnit >= 1.58)

我的梦境 提交于 2019-12-18 10:33:50
问题 It seems like this should be easy to integrate CMake+CTest in jenkins. The cmakebuilder plugin is extremely easy to configure (just set the source tree and the build tree, done!). However I fail to understand how to call the CTest steps. According to the main xUnit page, since version 1.58 the XML output from CTest is supported, see bug report. That's about all the documentation I could find. When I search on google or on stackoverflow, I can only find very old documentation requiring manual

CMakeLists.txt: How to print a message if ctest fails?

匆匆过客 提交于 2019-12-13 19:49:38
问题 Is there a way I can setup CMakeLists.txt to print a message if ctest tests fail? For example: cmake .. make ctest // fails message output: Please contact xyz@mail.com to resolve testing problems. 回答1: You can use message, which can help you output information to the configuration log process. 来源: https://stackoverflow.com/questions/36629644/cmakelists-txt-how-to-print-a-message-if-ctest-fails

CMake: How to Unit-Test your own CMake Script Macros/Functions?

霸气de小男生 提交于 2019-12-13 17:06:17
问题 I've written some convenience wrappers around standard CMake commands and want to unit-test this CMake script code to ensure its functionality. I've made some progress, but there are two things I hope to get help with: Is there some "official" way of unit-testing your own CMake script code? Something like a special mode to run CMake in? My goal is "white-box testing" (as much as possible). How do I handle the global variables and the variable scopes issues? Inject Global variables into the

CTest build ID not set

六眼飞鱼酱① 提交于 2019-12-12 10:15:04
问题 I have a CDash configured to accept posts for automatic builds and tests. However, when any system attempts to post results to the CDash, the following error is produced. The result is that each result gets posted four times (presumably the original posting attempt plus the three retries). Can anyone give me a hint as to what sets this mysterious build ID? I found some code that seems to produce a similar error, but still no lead on what might be happening. Build::GetNumberOfErrors(): BuildId

CMake in QtCreator 4.3 shows many automatic targets, how to remove/hide them?

╄→гoц情女王★ 提交于 2019-12-11 05:27:11
问题 I just switched to the last version of QtCreator (4.3.1) and the project explorer now shows many targets like ContinuousBuild, ContinuousConfigure, NightlyBuild, ExperimentalCoverage etc. How can I remove all of these (or at least hide them) ? I don't even know where this is generated in CMake. Seems to be related to this question Hide automatically generated CTest targets except that I am not using CLion. 回答1: You are probably using somewhere: include(CTest) According to the documentation:

How to pass arguments to memcheck with ctest?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:06:10
问题 I want to use ctest from the command line to run my tests with memcheck and pass in arguments for the memcheck command. I can run ctest -R my_test to run my test, and I can even run ctest -R my_test -T memcheck to run it through memcheck. But I can't seem to find a way to pass arguments to that memcheck command, like --leak-check=full or --suppressions=/path/to/file . After reading ctest's documentation I've tried using the -D option with CTEST_MEMCHECK_COMMAND_OPTIONS and MEMCHECK_COMMAND