How to specify multiple exclusion filters in --gtest_filter?
Asked Answered
J

2

140

The question is about google-test framework. I want to run all tests excluding some according to multiple exclusion filters, like: --gtest_filter=-ABC.*:-BCD.*

Jessiejessika answered 24/12, 2012 at 7:29 Comment(0)
V
181

You group the patterns in the form --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]

So in this case, you want --gtest_filter=-ABC.*:BCD.*

Vassal answered 24/12, 2012 at 13:25 Comment(2)
Great. It took me a while what the grouping meant and the exact difference between the example of the OP and the answer. Notice the '-' character is a single character that affects both expressions. The op on the other hand adds the '-' character to each expression.Kursh
But a bit of explanation that I need a SINGLE '-' character before all negative patterns instead of adding it to each filter would be nice. I had to read the answer 3 times to understand that it is indeed a correct answer (and actually a @PauloNeves 's comment helped)Smoothshaven
C
37

See https://blogs.msdn.microsoft.com/taxiahou/2013/07/30/the-usage-of-running-a-subset-of-tests-in-google-test-framework-gtest_filter/. You can find a clear example there.

Exclusions are identified by '-' sign. You can say multiple seperated by :. no need of repeating - with :.

--gtest_filter=-*str* :This will run tests that don't contain string "str".

--gtest_filter=-*str1*:*str2* :This will run tests that don't contain either "str1" or "str2":

--gtest_filter=*str*:-*str1*:*str2* :This will run tests that contain str and that do not contain either str1 or str2.

So, anything followed by '-' will be counted for exclusion list.

So, in your case it will be --gtest_filter=-ABC.*:BCD.*

Corked answered 13/11, 2019 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.