How to pass command-line arguments in CTest at runtime

I’ve figured out a way to do it (using the Fundamental theorem of software engineering). It’s not as simple as I’d like, but here it is. First, create a file ${CMAKE_SOURCE_DIR}/cmake/RunTests.cmake with the content if(NOT DEFINED ENV{TESTS_ARGUMENTS}) set(ENV{TESTS_ARGUMENTS} “–default-arguments”) endif() execute_process(COMMAND ${TEST_EXECUTABLE} $ENV{TESTS_ARGUMENTS} RESULT_VARIABLE result) if(NOT “${result}” STREQUAL “0”) message(FATAL_ERROR “Test failed with return value … Read more

Build Qt Tests with CMake

Here is an example of using cmake 2.8.11 and Qt5.2. Note that cmake now supports testfiles with a .moc-include at the bottom. CMakeLists.txt: cmake_minimum_required(VERSION 2.8.11) project(foo) enable_testing() # Tell CMake to run moc when necessary: set(CMAKE_AUTOMOC ON) # As moc files are generated in the binary dir, tell CMake # to always look for includes … Read more

How to run ctest after building my project with cmake

This form of add_custom_command will only execute if another CMake target has a dependency on “tests.txt”. I assume that no other target has “tests.txt” as an input file, hence the custom command never runs. I think you could use the second form of add_custom_command to achieve your goal; something like: add_custom_command(TARGET MainTest POST_BUILD COMMAND ctest … Read more

CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)

The built-in test target cannot be modified, but you can add a custom check target which invokes ctest with the –output-on-failure switch in the following way: if (CMAKE_CONFIGURATION_TYPES) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} –force-new-ctest-process –output-on-failure –build-config “$<CONFIGURATION>”) else() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} –force-new-ctest-process –output-on-failure) endif() The custom target has to be set up differently for single build type … Read more

CMake & CTest : make test doesn’t build tests

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_COMMAND} DEPENDS ExeName) Then you can run make check and it will compile and run the test. If you have several tests, then you would have … Read more

Using CMake, how do I get verbose output from CTest?

You can use the ctest –output-on-failure option, or set the environment variable CTEST_OUTPUT_ON_FAILURE, which will show you any output from the test program whenever the test fails. One way to do this when using Makefiles and the command line would be as follows: env CTEST_OUTPUT_ON_FAILURE=1 make check This Stack Overflow question and answer shows how to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)