Regex for labels in ctest_test

Hello,

I have several tests described with some of them having multiple labels. I am trying to run tests with multiple labels, like label_A and label_B, in ctest_test(). I am not able to get a regex work for this case, for the LABELS field of ctest_test(). Have tried a few combinations of POSIX regex, but haven’t been successful. I might be doing something stupid here, Any help would be appreciated :smiling_face:

Thanks

This is probably easiest:

set(labels
  "^label1$"
  "^label2$")
string(REPLACE ";" "|" labels "${labels}")
ctest_test(… LABELS "${labels}")

Thanks for the reply Ben :slight_smile:
I am looking to run a set of tests that are intersection of 2 labels. Only if the tests have both the labels, I would like to run them. Is there a way to represent that in posix regex for ctest_test()

I tried the answer at regex - Regular Expressions: Is there an AND operator? - Stack Overflow , does not help unfortunately.

Something like

ctest_test( APPEND 
            INCLUDE_LABEL "(?=^label1$)(?=^label2$)" 

I get the following error:

RegularExpression::compile(): ?+* follows nothing.
RegularExpression::compile(): Error in compile.

Also to clarify, my add test looks like this

set_tests_properties(testA PROPERTIES 
      LABELS "label1;label2"

I don’t believe so as each label is (IIRC) tested against the regex individually. Using this proposed feature with ctest -N -L label1 and using sort and uniq -d to craft a test list would probably be the easiest solution.