-
Notifications
You must be signed in to change notification settings - Fork 117
[feat] Add support for selecting tests using regular expressions #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Add support for selecting tests using regular expressions #664
Conversation
|
Hello @ChristopherBignamini, Thank you for updating! Cheers! There are no PEP8 issues in this Pull Request!Do see the ReFrame Coding Style Guide Comment last updated at 2019-03-15 08:59:08 UTC |
|
I forgot to mention that for the moment I have left all the old selection options, I will remove them when the new regexp based ones will have a final form (the old ones are useful for debugging) |
Codecov Report
@@ Coverage Diff @@
## master #664 +/- ##
==========================================
- Coverage 91.83% 91.82% -0.01%
==========================================
Files 77 77
Lines 9494 9498 +4
==========================================
+ Hits 8719 8722 +3
- Misses 775 776 +1
Continue to review full report at Codecov.
|
vkarak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the existing filter functions. It would be easier to see the exact differences. Thanks to git we can retrieve the current implementation easily.
|
@ChristopherBignamini Unit tests are broken. Can you fix them before the review? |
|
@jenkins-cscs retry daint |
vkarak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still a couple of issues in the API, so I'm not going to do a detailed review of the implementation yet. I will come back again with more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have worked a bit on the API and I have some general comments/suggestions:
- The filter functions must take a regex pattern string, not a regex object.
- The filter functions will compile the regex object in the closure of the actual filter functions that will be passed subsequently to the
filter()function. - The filter functions should remain simple. They will only take a single regex pattern as argument. The CLI will do the multiple filterings for each of the options passed.
- Multiple
-nand-xoptions specified in the command line are essentially OR-ed (or AND-ed for the-xoption). With the support for regular expressions, supporting passing-nand-xmultiple times is redundant, since-n A -n Bis equivalent of-n 'A|B'and-x A -x Bis equivalent of-x 'A|B'. Since we cannot drop the support for multiple-nand-xoptions for the moment, we can aggregate them in a single regex before passing them to the filtering functions. We should decide whether we will drop support for multiple-nand-xoptions in the future and, therefore, we need also to issue a deprecation warning. - Filtering per programming environments. There is a major complication with this right now and this comes from the fact that we support wildcards for the
valid_prog_environsattribute. Ideally, we would need a way to figure out that the set of values covered by thevalid_prog_environspatterns is a subset of the values covered by the regex passed in the-poption. This is not trivial at all! So I suggest to completely drop the support of wildcards for thevalid_prog_environsexcept for the*special value that denotes any environment. I was never warm in supporting wildcards invalid_prog_environsand now there is a good reason to drop them. We are not using them in any case. As soon as we drop them, we can write the filtering function in the same way that we would do that for the tags, for example.
Here is a proposal of the implementation of the filtering functions (not tested):
def have_name(patt):
regex = re.compile(patt)
def _fn(c):
return c if regex.match(c.name) else None
return _fn
def have_not_name(names):
def _fn(c):
return not have_name(names)(c)
return _fn
def have_prgenv(patt):
regex = re.compile(patt)
def _fn(c):
if '*' in c.valid_prog_environs:
return c
else:
return c if any(regex.match(p) for p in c.valid_prog_environs)
return _fn
def have_tag(patt):
regex = re.compile(patt)
def _fn(c):
return c if any(regex.match(p) for p in c.tags)
return _fn
# inside the CLI
def main():
...
for t in options.tags:
checks_matched = filter(have_tag(t), checks_matched)
# similarly for the other options, except the `-n` and `-x`.@victorusu @teojgo Please give some feedback on my comments above.
|
As @ChristopherBignamini pointed out, my suggestion has a small mistake. The internal |
|
@jenkins-cscs retry daint |
victorusu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
vkarak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall and works nicely! My comments are minor. What we still miss is to remove support for wildcards in the definition of the valid_prog_environs. It should only accept the special value *. Additional to this is to update the documentation of the valid_prog_environs attribute.
|
@ChristopherBignamini Please try to fix the coding style issues reported by @pep8speaks. |
Also - Remove unit tests for wildcards in `valid_prog_environs`.
|
@teojgo Can you also approve? |
Co-Authored-By: ChristopherBignamini <bignamini@cscs.ch>
@vkarak I'm still using the search method instead of the match one because I have the impression that in this way we can provide more flexibility to the user, who could get a "match" behavior by adding the ^ special character to his regexp.
Fixes #69.