0

What is the approach to create a new target for Ctest?

By default, the target 'test' is created and CTest can be run from

make test

Let say that this command line runs some tests defined like this:

ADD_TEST(my_test1 my_exe1 my_arg1) 
ADD_TEST(my_test2 my_exe2 my_arg2)

Is it possible to create a new target 'check' such as

make check

runs my_test1 with CTest and

make test

runs my_test2 with CTest?

Aleph
  • 1,343
  • 1
  • 12
  • 27

1 Answers1

0

The built-in test target cannot be modified, it will always run all tests defined in the project. You can however add custom targets check1 and check2 which only run the desired tests in the following way:

add_custom_target(check1 COMMAND 
    ${CMAKE_CTEST_COMMAND}
    --force-new-ctest-process
    --tests-regex "^my_test1$"
    --build-config $<CONFIGURATION>)

add_custom_target(check2 COMMAND 
    ${CMAKE_CTEST_COMMAND}
    --force-new-ctest-process
    --tests-regex "^my_test2$"
    --build-config $<CONFIGURATION>)
sakra
  • 62,199
  • 16
  • 168
  • 151