sixty-north / cosmic-ray

Mutation testing for Python
MIT License
556 stars 54 forks source link

[Question] How Do Regular Expressions Work When Excluding Operator Filters? #520

Closed FloatingSunfish closed 3 years ago

FloatingSunfish commented 3 years ago

The cr-filter-operators section of the documentation shows the following examples:

"core/ReplaceComparisonOperator_Is(Not)?_(Not)?(Eq|[LG]tE?)",
"core/ReplaceComparisonOperator_(Not)?(Eq|[LG]tE?)_Is(Not)?",
"core/ReplaceComparisonOperator_[LG]tE_Eq",
"core/ReplaceComparisonOperator_[LG]t_NotEq",

Because regular expressions are optional, and the operator's full name is already included, how are the regular expressions affecting the configuration?

You can provide an explanation for just one of the examples.

abingham commented 3 years ago

I'm not entirely sure I understand the question, but I've updated the docs to hopefully make things clearer.

Because regular expressions are optional

They're not. Every string in that list is treated as a regular expression, if it's a very simple regex that only matches a single string.

the operator's full name is already included, how are the regular expressions affecting the configuration?

This is where I'm not sure I understand. The filter looks at the operator name for each WorkItem, and if that operator name matches any of the regular expressions the list, that WorkItem is skipped. The use of regular expressions allows you to match on many operator names with a single pattern.

If the documentation changes clarify things, go ahead and close this. Thanks!

FloatingSunfish commented 3 years ago

@abingham I assumed regular expressions were optional because of what you said here:

>Yes, that looks correct. Regular expressions are an option, not a requirement. In your case of excluding a single operator, what you've done is fine.

Perhaps I misunderstood what you meant to say. In any case, after seeing the updated section in the docs, I think everything is clear to me now. 🙂

But before we close this issue, could you clarify what you meant in the quote above?

abingham commented 3 years ago

I was just being sloppy with my language. What I meant by "regular expressions are an option" is that you don't need to use any "special" regular expression syntax in those strings; you can just match on a simple string without repetition operators, choice operators, etc.

So just to restate things: all of the strings in that list are used as regular expressions, and simple strings without fancy regex features are perfectly valid regular expressions.