labelctest

ctest - run tests having 2 labels


lest assume I have some project that consists of N domains (D1, D2, ... , DN) . Each domain has tests of two kinds: lest say UT and MT. They are defined like so:

add_test(
  NAME Di_UT
  COMMAND <blah>
)

add_test(
  NAME Di_MT
  COMMAND <blah>
)

And I'd like to be able to filter them by labels. So I add the labels:

set_tests_properties(Di_UT PROPERTIES LABELS "UT;Di")
set_tests_properties(Di_MT PROPERTIES LABELS "MT;Di")

Then I execute ctest:

ctest -L Di

will execute all tests for domain Di, and of course the opposite:

ctest -L UT

Will execute all tests with UT label.

But how to filter by both labels? execute only UT for domain Di?

From what i observe, passing multiple -L causes them to overwrite. (the last one has effect). Any other ideas? my cmake version is

ctest version 3.13.4


Solution

  • It seems that such thing is simply not supported. So as a workaround, I am simply adding a 3rd label containig the other two - and then pas it to ctest. So:

    add_test(
      NAME Di_UT
      COMMAND <blah>
    )
    
    set_tests_properties(Di_UT PROPERTIES LABELS "UT;Di;UT-Di")
    
    add_test(
      NAME Di_MT
      COMMAND <blah>
    )
    set_tests_properties(Di_MT PROPERTIES LABELS "MT;Di;MT-Di")
    

    So then i can execute like so:

    execute all UT:

    ctest -L UT
    

    execute all Tests for domain Di:

    ctest -L Di
    

    execute only UT for Di:

    ctest -L Ut-Di
    

    This seems only available option.