fmf icon indicating copy to clipboard operation
fmf copied to clipboard

Add support for escaping `|` in `utils.filter()`

Open psss opened this issue 2 years ago • 4 comments

Pull Request Checklist

  • [x] implement the feature
  • [ ] write the documentation
  • [ ] extend the test coverage

psss avatar Jan 23 '24 15:01 psss

@lukaszachy Any regexp where | is quite common, e.g. tmt test ls --filter 'name: (/setup\|/functional).*'.

The-Mule avatar May 13 '24 15:05 The-Mule

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'

lukaszachy avatar May 13 '24 15:05 lukaszachy

It's split of the filter() clause versus regular expression. See my comment in the related issue reported by @kkaarreell.

psss avatar May 13 '24 15:05 psss

Let's include escaping of & as well.

psss avatar May 14 '24 08:05 psss

Found this PR only after commenting at https://github.com/teemtee/fmf/pull/219#discussion_r1624484311

martinhoyer avatar Jun 03 '24 14:06 martinhoyer