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
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.
I've been struggling with this too. It's such a pity that such feature is not supported, especially if you consider that the logical or works:
ctest -L 'label1|label2'
What I came up with is to create my own bash function which boils down to the following:
ctest -R "$(echo "$(ctest -N -L label1 | awk '/Test #/ { print $3}')" | tr '\n' '|')" -L label2
I know, it's a bit ugly, but let's break it down.
Test #xyz: first).\n with |.It's quite cumbersome, especially if you want to run tests that have N labels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With