Add support for escaping `|` in `utils.filter()`
Pull Request Checklist
- [x] implement the feature
- [ ] write the documentation
- [ ] extend the test coverage
@lukaszachy Any regexp where | is quite common, e.g. tmt test ls --filter 'name: (/setup\|/functional).*'.
So re.sub doesn't work as expected, or? I'd assume that it intention is to 'undo' the escaping.
BTW it would be really good to see this covered in unit tests...
import re
>>> clause = re.split(r"\s*(?<!\\)\|\s*", r'foo\|bar|baz')[0]
>>> clause
'foo\\|bar'
>>> re.sub(r"\|", "|", clause)
'foo\\|bar'
It's split of the filter() clause versus regular expression. See my comment in the related issue reported by @kkaarreell.
Let's include escaping of & as well.
Found this PR only after commenting at https://github.com/teemtee/fmf/pull/219#discussion_r1624484311