From a55512654086fd5b05b1d30425bb4baf0712a6f9 Mon Sep 17 00:00:00 2001 From: bignamic Date: Thu, 17 Jan 2019 16:25:03 +0100 Subject: [PATCH 01/12] Regexp base test name selection option testing --- reframe/frontend/check_filters.py | 12 ++++++++++++ reframe/frontend/cli.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 8a7f32621c..1866b82aae 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -1,3 +1,5 @@ +import re + import reframe.core.runtime as rt import reframe.utility.sanity as util @@ -9,6 +11,16 @@ def _fn(c): return _fn +def have_name_regexp(regexp_names): + def _fn(c): + p = re.compile(regexp_names[0], re.IGNORECASE) + m = p.findall(c.name) + if m: + return c.name + + return _fn + + def have_not_name(names): def _fn(c): return not have_name(names)(c) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 97a44c2037..56bac66f6d 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -105,6 +105,9 @@ def main(): select_options.add_argument( '-n', '--name', action='append', dest='names', default=[], metavar='NAME', help='Select checks with NAME') + select_options.add_argument( + '-ren', '--regexp_name', action='append', dest='regexp_names', default=[], + metavar='NAME', help='Select checks with NAME') select_options.add_argument( '-x', '--exclude', action='append', dest='exclude_names', metavar='NAME', default=[], help='Exclude checks with NAME') @@ -412,6 +415,10 @@ def main(): checks_matched = filter(filters.have_name(options.names), checks_matched) + # Filter checks by regular expression for name + if options.regexp_names: + checks_matched = filter(filters.have_name_regexp(options.regexp_names),checks_matched) + # Filter checks by tags checks_matched = filter(filters.have_tag(options.tags), checks_matched) From f07fe71f731a219dbe8befc95f659f5e9d2ced84 Mon Sep 17 00:00:00 2001 From: bignamic Date: Tue, 22 Jan 2019 16:36:25 +0100 Subject: [PATCH 02/12] Regexp test filtering function for prgenv created --- reframe/frontend/check_filters.py | 11 +++++++++++ reframe/frontend/cli.py | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 1866b82aae..0b5b557e66 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -45,6 +45,17 @@ def _fn(c): return _fn +def have_prgenv_regexp(regexp_prgenv): + def _fn(c): + if regexp_prgenv: + p = re.compile(regexp_prgenv, re.IGNORECASE) + return any(len(p.findall(prgenv)) > 0 for prgenv in c.valid_prog_environs) + else: + return bool(c.valid_prog_environs) + + return _fn + + def have_partition(partitions): def _fn(c): return any([c.supports_system(s.fullname) for s in partitions]) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 56bac66f6d..d0ca937858 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -114,6 +114,9 @@ def main(): select_options.add_argument( '-p', '--prgenv', action='append', default=[], help='Select tests for PRGENV programming environment only') + select_options.add_argument( + '-rep', '--regexp_prgenv', action='append', default=[], + help='Select tests for PRGENV programming environment only') select_options.add_argument( '--gpu-only', action='store_true', help='Select only GPU tests') @@ -417,7 +420,7 @@ def main(): # Filter checks by regular expression for name if options.regexp_names: - checks_matched = filter(filters.have_name_regexp(options.regexp_names),checks_matched) + checks_matched = filter(filters.have_name_regexp(options.regexp_names[0]),checks_matched) # Filter checks by tags checks_matched = filter(filters.have_tag(options.tags), checks_matched) @@ -427,6 +430,11 @@ def main(): checks_matched = filter(filters.have_prgenv(options.prgenv), checks_matched) + # Filter checks by regular expression for prgenv + if not options.skip_prgenv_check: + checks_matched = filter(filters.have_prgenv_regexp(options.regexp_prgenv[0]), + checks_matched) + # Filter checks by system if not options.skip_system_check: checks_matched = filter( From 5b37e831d8c78a360620c83035cffcde60f5f99b Mon Sep 17 00:00:00 2001 From: bignamic Date: Wed, 30 Jan 2019 11:59:05 +0100 Subject: [PATCH 03/12] Regexp check filtering functions implemented --- reframe/frontend/check_filters.py | 31 +++++++++++--- reframe/frontend/cli.py | 31 +++++++++++--- unittests/test_check_filters.py | 67 +++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 12 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 0b5b557e66..905485c68b 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -13,10 +13,9 @@ def _fn(c): def have_name_regexp(regexp_names): def _fn(c): - p = re.compile(regexp_names[0], re.IGNORECASE) - m = p.findall(c.name) - if m: - return c.name + for p in regexp_names: + if p.search(c.name): + return c.name return _fn @@ -28,6 +27,13 @@ def _fn(c): return _fn +def have_not_name_regexp(regexp_names): + def _fn(c): + return not have_name_regexp(regexp_names)(c) + + return _fn + + def have_tag(tags): def _fn(c): return (set(tags)).issubset(c.tags) @@ -35,6 +41,17 @@ def _fn(c): return _fn +def have_tag_regexp(regexp_tags): + def _fn(c): + if regexp_tags: + for p in regexp_tags: + if(any(p.search(tag) for tag in c.tags) == False): + return False + return True + + return _fn + + def have_prgenv(prgenv): def _fn(c): if prgenv: @@ -48,8 +65,10 @@ def _fn(c): def have_prgenv_regexp(regexp_prgenv): def _fn(c): if regexp_prgenv: - p = re.compile(regexp_prgenv, re.IGNORECASE) - return any(len(p.findall(prgenv)) > 0 for prgenv in c.valid_prog_environs) + for p in regexp_prgenv: + if(any(p.search(prgenv) for prgenv in c.valid_prog_environs) == False): + return False + return True else: return bool(c.valid_prog_environs) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index d0ca937858..f76e298d4d 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -1,6 +1,7 @@ -import os import inspect import json +import os +import re import socket import sys @@ -102,6 +103,9 @@ def main(): select_options.add_argument( '-t', '--tag', action='append', dest='tags', default=[], help='Select checks matching TAG') + select_options.add_argument( + '-ten', '--regexp_tag', action='append', dest='regexp_tags', default=[], + help='Select checks matching TAG') select_options.add_argument( '-n', '--name', action='append', dest='names', default=[], metavar='NAME', help='Select checks with NAME') @@ -111,6 +115,9 @@ def main(): select_options.add_argument( '-x', '--exclude', action='append', dest='exclude_names', metavar='NAME', default=[], help='Exclude checks with NAME') + select_options.add_argument( + '-xen', '--regexp_exclude', action='append', dest='regexp_exclude_names', + metavar='NAME', default=[], help='Exclude checks with NAME') select_options.add_argument( '-p', '--prgenv', action='append', default=[], help='Select tests for PRGENV programming environment only') @@ -414,26 +421,38 @@ def main(): checks_matched = filter(filters.have_not_name(options.exclude_names), checks_found) + # TODO: remove old filter functions and use checks_found as input for this step + p = [re.compile(regexp) for regexp in options.regexp_exclude_names] + checks_matched = filter(filters.have_not_name_regexp(p), + checks_found) + if options.names: checks_matched = filter(filters.have_name(options.names), checks_matched) - # Filter checks by regular expression for name if options.regexp_names: - checks_matched = filter(filters.have_name_regexp(options.regexp_names[0]),checks_matched) + # TODO: should I merge the input regexp string into a single regexp? + p = [re.compile(regexp) for regexp in options.regexp_names] + checks_matched = filter(filters.have_name_regexp(p), checks_matched) # Filter checks by tags checks_matched = filter(filters.have_tag(options.tags), checks_matched) + # Filter checks by regular expression for tags + checks_matched = filter(filters.have_tag_regexp([ + re.compile(regexp) for regexp in options.regexp_tags]), checks_matched) + # Filter checks by prgenv if not options.skip_prgenv_check: checks_matched = filter(filters.have_prgenv(options.prgenv), checks_matched) - # Filter checks by regular expression for prgenv + # Filter checks by regular expression for prgenvs if not options.skip_prgenv_check: - checks_matched = filter(filters.have_prgenv_regexp(options.regexp_prgenv[0]), - checks_matched) + if len(options.regexp_prgenv)>0: + p = [re.compile(regexp) for regexp in options.regexp_prgenv] + checks_matched = filter(filters.have_prgenv_regexp(p), + checks_matched) # Filter checks by system if not options.skip_system_check: diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 4e20b91c87..4a25d4aa1e 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -1,3 +1,4 @@ +import re import unittest import reframe.core.runtime as rt @@ -47,10 +48,50 @@ def test_have_name(self): self.assertEqual(0, sn.count(filter(filters.have_name('check4'), self.checks))) + def test_have_name_regexp(self): + p = [re.compile('check1')] + self.assertEqual(1, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + p = [re.compile('check')] + self.assertEqual(3, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + p = [re.compile('.1|.3')] + self.assertEqual(2, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + p = [re.compile('Check')] + self.assertEqual(0, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + p = [re.compile('(?i)Check')] + self.assertEqual(3, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + p = [re.compile('check1'), re.compile('(?i)CHECK2')] + self.assertEqual(2, sn.count(filter(filters.have_name_regexp(p), + self.checks))) + def test_have_not_name(self): self.assertEqual(2, sn.count(filter(filters.have_not_name('check1'), self.checks))) + def test_have_not_name_regexp(self): + p = [re.compile('check1')] + self.assertEqual(2, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + p = [re.compile('check1'), re.compile('check3')] + self.assertEqual(1, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + p = [re.compile('check1'), re.compile('check2'), re.compile('check3')] + self.assertEqual(0, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + p = [re.compile('Check1')] + self.assertEqual(3, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + p = [re.compile('Check1')] + self.assertEqual(3, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + p = [re.compile('(?i)Check1')] + self.assertEqual(2, sn.count(filter(filters.have_not_name_regexp(p), + self.checks))) + def test_have_tags(self): self.assertEqual(1, sn.count(filter(filters.have_tag(['a', 'c']), self.checks))) @@ -59,6 +100,17 @@ def test_have_tags(self): self.assertEqual(2, sn.count(filter(filters.have_tag(['z']), self.checks))) + def test_have_tags_regexp(self): + p = [re.compile('a'), re.compile('c')] + self.assertEqual(1, sn.count(filter(filters.have_tag_regexp(p), + self.checks))) + p = [re.compile('p'), re.compile('q')] + self.assertEqual(0, sn.count(filter(filters.have_tag_regexp(p), + self.checks))) + p = [re.compile('z')] + self.assertEqual(2, sn.count(filter(filters.have_tag_regexp(p), + self.checks))) + def test_have_prgenv(self): self.assertEqual(1, sn.count(filter( filters.have_prgenv(['env1', 'env2']), self.checks))) @@ -69,6 +121,21 @@ def test_have_prgenv(self): self.assertEqual(0, sn.count(filter( filters.have_prgenv(['env1', 'env3']), self.checks))) + def test_have_prgenv_regexp(self): + p = [re.compile('env1'), re.compile('env2')] + self.assertEqual(1, sn.count(filter( + filters.have_prgenv_regexp(p), self.checks))) + p = [re.compile('env3')] + self.assertEqual(2, sn.count(filter(filters.have_prgenv_regexp(p), + self.checks))) + p = [re.compile('env4')] + self.assertEqual(1, sn.count(filter(filters.have_prgenv_regexp(p), + self.checks))) + p = [re.compile('env1'), re.compile('env3')] + self.assertEqual(0, sn.count(filter( + filters.have_prgenv_regexp(p), self.checks))) + + @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') def test_partition(self): p = rt.runtime().system.partition('gpu') From 46aaab869ccef0d6fe0b926aae2b21d33057ae2e Mon Sep 17 00:00:00 2001 From: bignamic Date: Wed, 30 Jan 2019 14:38:04 +0100 Subject: [PATCH 04/12] Coding style fixes --- reframe/frontend/check_filters.py | 5 +++-- reframe/frontend/cli.py | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 905485c68b..a6f4813d14 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -45,7 +45,7 @@ def have_tag_regexp(regexp_tags): def _fn(c): if regexp_tags: for p in regexp_tags: - if(any(p.search(tag) for tag in c.tags) == False): + if(any(p.search(tag) for tag in c.tags) is False): return False return True @@ -66,7 +66,8 @@ def have_prgenv_regexp(regexp_prgenv): def _fn(c): if regexp_prgenv: for p in regexp_prgenv: - if(any(p.search(prgenv) for prgenv in c.valid_prog_environs) == False): + if(any(p.search(prgenv) for prgenv in c.valid_prog_environs) + is False): return False return True else: diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 354ac9127c..8912ce1b10 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -108,20 +108,23 @@ def main(): '-t', '--tag', action='append', dest='tags', default=[], help='Select checks matching TAG') select_options.add_argument( - '-ten', '--regexp_tag', action='append', dest='regexp_tags', default=[], + '-ten', '--regexp_tag', action='append', dest='regexp_tags', + default=[], help='Select checks matching TAG') select_options.add_argument( '-n', '--name', action='append', dest='names', default=[], metavar='NAME', help='Select checks with NAME') select_options.add_argument( - '-ren', '--regexp_name', action='append', dest='regexp_names', default=[], + '-ren', '--regexp_name', action='append', dest='regexp_names', + default=[], metavar='NAME', help='Select checks with NAME') select_options.add_argument( '-x', '--exclude', action='append', dest='exclude_names', metavar='NAME', default=[], help='Exclude checks with NAME') select_options.add_argument( - '-xen', '--regexp_exclude', action='append', dest='regexp_exclude_names', - metavar='NAME', default=[], help='Exclude checks with NAME') + '-xen', '--regexp_exclude', action='append', + dest='regexp_exclude_names', metavar='NAME', default=[], + help='Exclude checks with NAME') select_options.add_argument( '-p', '--prgenv', action='append', default=[], help='Select tests for PRGENV programming environment only') @@ -430,7 +433,7 @@ def main(): checks_matched = filter(filters.have_not_name(options.exclude_names), checks_found) - # TODO: remove old filter functions and use checks_found as input for this step + # TODO: remove old filter functions and use checks_found p = [re.compile(regexp) for regexp in options.regexp_exclude_names] checks_matched = filter(filters.have_not_name_regexp(p), checks_found) @@ -440,16 +443,18 @@ def main(): checks_matched) if options.regexp_names: - # TODO: should I merge the input regexp string into a single regexp? + # TODO: should I merge the input string into a single regexp? p = [re.compile(regexp) for regexp in options.regexp_names] - checks_matched = filter(filters.have_name_regexp(p), checks_matched) + checks_matched = filter(filters.have_name_regexp(p), + checks_matched) # Filter checks by tags checks_matched = filter(filters.have_tag(options.tags), checks_matched) # Filter checks by regular expression for tags checks_matched = filter(filters.have_tag_regexp([ - re.compile(regexp) for regexp in options.regexp_tags]), checks_matched) + re.compile(regexp) for regexp in options.regexp_tags]), + checks_matched) # Filter checks by prgenv if not options.skip_prgenv_check: @@ -458,7 +463,7 @@ def main(): # Filter checks by regular expression for prgenvs if not options.skip_prgenv_check: - if len(options.regexp_prgenv)>0: + if len(options.regexp_prgenv) > 0: p = [re.compile(regexp) for regexp in options.regexp_prgenv] checks_matched = filter(filters.have_prgenv_regexp(p), checks_matched) From 3216371f11fff98aef5e4417a66c260ac7920f47 Mon Sep 17 00:00:00 2001 From: bignamic Date: Tue, 12 Feb 2019 14:12:14 +0100 Subject: [PATCH 05/12] Old filtering functions reblaced by the regexp based ones --- reframe/frontend/check_filters.py | 41 +++--------------- reframe/frontend/cli.py | 49 ++++----------------- unittests/test_check_filters.py | 71 +++++++++---------------------- 3 files changed, 34 insertions(+), 127 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index a6f4813d14..06d3207561 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -4,14 +4,7 @@ import reframe.utility.sanity as util -def have_name(names): - def _fn(c): - return c.name in names - - return _fn - - -def have_name_regexp(regexp_names): +def have_name(regexp_names): def _fn(c): for p in regexp_names: if p.search(c.name): @@ -20,28 +13,14 @@ def _fn(c): return _fn -def have_not_name(names): - def _fn(c): - return not have_name(names)(c) - - return _fn - - -def have_not_name_regexp(regexp_names): - def _fn(c): - return not have_name_regexp(regexp_names)(c) - - return _fn - - -def have_tag(tags): +def have_not_name(regexp_names): def _fn(c): - return (set(tags)).issubset(c.tags) + return not have_name(regexp_names)(c) return _fn -def have_tag_regexp(regexp_tags): +def have_tag(regexp_tags): def _fn(c): if regexp_tags: for p in regexp_tags: @@ -52,17 +31,7 @@ def _fn(c): return _fn -def have_prgenv(prgenv): - def _fn(c): - if prgenv: - return util.allx(c.supports_environ(e) for e in prgenv) - else: - return bool(c.valid_prog_environs) - - return _fn - - -def have_prgenv_regexp(regexp_prgenv): +def have_prgenv(regexp_prgenv): def _fn(c): if regexp_prgenv: for p in regexp_prgenv: diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 523baff353..694393cc5b 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -104,30 +104,15 @@ def main(): select_options.add_argument( '-t', '--tag', action='append', dest='tags', default=[], help='Select checks matching TAG') - select_options.add_argument( - '-ten', '--regexp_tag', action='append', dest='regexp_tags', - default=[], - help='Select checks matching TAG') select_options.add_argument( '-n', '--name', action='append', dest='names', default=[], metavar='NAME', help='Select checks with NAME') - select_options.add_argument( - '-ren', '--regexp_name', action='append', dest='regexp_names', - default=[], - metavar='NAME', help='Select checks with NAME') select_options.add_argument( '-x', '--exclude', action='append', dest='exclude_names', metavar='NAME', default=[], help='Exclude checks with NAME') - select_options.add_argument( - '-xen', '--regexp_exclude', action='append', - dest='regexp_exclude_names', metavar='NAME', default=[], - help='Exclude checks with NAME') select_options.add_argument( '-p', '--prgenv', action='append', default=[], help='Select tests for PRGENV programming environment only') - select_options.add_argument( - '-rep', '--regexp_prgenv', action='append', default=[], - help='Select tests for PRGENV programming environment only') select_options.add_argument( '--gpu-only', action='store_true', help='Select only GPU tests') @@ -429,42 +414,26 @@ def main(): raise ReframeError from e # Filter checks by name - checks_matched = filter(filters.have_not_name(options.exclude_names), - checks_found) - - # TODO: remove old filter functions and use checks_found - p = [re.compile(regexp) for regexp in options.regexp_exclude_names] - checks_matched = filter(filters.have_not_name_regexp(p), + p = [re.compile(regexp) for regexp in options.exclude_names] + checks_matched = filter(filters.have_not_name(p), checks_found) if options.names: - checks_matched = filter(filters.have_name(options.names), - checks_matched) - - if options.regexp_names: # TODO: should I merge the input string into a single regexp? - p = [re.compile(regexp) for regexp in options.regexp_names] - checks_matched = filter(filters.have_name_regexp(p), + p = [re.compile(regexp) for regexp in options.names] + checks_matched = filter(filters.have_name(p), checks_matched) # Filter checks by tags - checks_matched = filter(filters.have_tag(options.tags), checks_matched) - - # Filter checks by regular expression for tags - checks_matched = filter(filters.have_tag_regexp([ - re.compile(regexp) for regexp in options.regexp_tags]), + checks_matched = filter(filters.have_tag([ + re.compile(regexp) for regexp in options.tags]), checks_matched) # Filter checks by prgenv if not options.skip_prgenv_check: - checks_matched = filter(filters.have_prgenv(options.prgenv), - checks_matched) - - # Filter checks by regular expression for prgenvs - if not options.skip_prgenv_check: - if len(options.regexp_prgenv) > 0: - p = [re.compile(regexp) for regexp in options.regexp_prgenv] - checks_matched = filter(filters.have_prgenv_regexp(p), + if len(options.prgenv) > 0: + p = [re.compile(regexp) for regexp in options.prgenv] + checks_matched = filter(filters.have_prgenv(p), checks_matched) # Filter checks by system diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 4a25d4aa1e..0a0964d73f 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -38,102 +38,71 @@ def setUp(self): 'num_gpus_per_node': 1}) ] - def test_have_name(self): - self.assertEqual(1, sn.count(filter(filters.have_name('check1'), - self.checks))) - self.assertEqual(1, sn.count(filter(filters.have_name('check2'), - self.checks))) - self.assertEqual(1, sn.count(filter(filters.have_name('check3'), - self.checks))) - self.assertEqual(0, sn.count(filter(filters.have_name('check4'), - self.checks))) - def test_have_name_regexp(self): + def test_have_name(self): p = [re.compile('check1')] - self.assertEqual(1, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(1, sn.count(filter(filters.have_name(p), self.checks))) p = [re.compile('check')] - self.assertEqual(3, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(3, sn.count(filter(filters.have_name(p), self.checks))) p = [re.compile('.1|.3')] - self.assertEqual(2, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_name(p), self.checks))) p = [re.compile('Check')] - self.assertEqual(0, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(0, sn.count(filter(filters.have_name(p), self.checks))) p = [re.compile('(?i)Check')] - self.assertEqual(3, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(3, sn.count(filter(filters.have_name(p), self.checks))) p = [re.compile('check1'), re.compile('(?i)CHECK2')] - self.assertEqual(2, sn.count(filter(filters.have_name_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_name(p), self.checks))) def test_have_not_name(self): - self.assertEqual(2, sn.count(filter(filters.have_not_name('check1'), - self.checks))) - - def test_have_not_name_regexp(self): p = [re.compile('check1')] - self.assertEqual(2, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_not_name(p), self.checks))) p = [re.compile('check1'), re.compile('check3')] - self.assertEqual(1, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(1, sn.count(filter(filters.have_not_name(p), self.checks))) p = [re.compile('check1'), re.compile('check2'), re.compile('check3')] - self.assertEqual(0, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(0, sn.count(filter(filters.have_not_name(p), self.checks))) p = [re.compile('Check1')] - self.assertEqual(3, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(3, sn.count(filter(filters.have_not_name(p), self.checks))) p = [re.compile('Check1')] - self.assertEqual(3, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(3, sn.count(filter(filters.have_not_name(p), self.checks))) p = [re.compile('(?i)Check1')] - self.assertEqual(2, sn.count(filter(filters.have_not_name_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_not_name(p), self.checks))) def test_have_tags(self): - self.assertEqual(1, sn.count(filter(filters.have_tag(['a', 'c']), - self.checks))) - self.assertEqual(0, sn.count(filter(filters.have_tag(['p', 'q']), - self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_tag(['z']), - self.checks))) - - def test_have_tags_regexp(self): p = [re.compile('a'), re.compile('c')] - self.assertEqual(1, sn.count(filter(filters.have_tag_regexp(p), + self.assertEqual(1, sn.count(filter(filters.have_tag(p), self.checks))) p = [re.compile('p'), re.compile('q')] - self.assertEqual(0, sn.count(filter(filters.have_tag_regexp(p), + self.assertEqual(0, sn.count(filter(filters.have_tag(p), self.checks))) p = [re.compile('z')] - self.assertEqual(2, sn.count(filter(filters.have_tag_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_tag(p), self.checks))) def test_have_prgenv(self): - self.assertEqual(1, sn.count(filter( - filters.have_prgenv(['env1', 'env2']), self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_prgenv(['env3']), - self.checks))) - self.assertEqual(1, sn.count(filter(filters.have_prgenv(['env4']), - self.checks))) - self.assertEqual(0, sn.count(filter( - filters.have_prgenv(['env1', 'env3']), self.checks))) - - def test_have_prgenv_regexp(self): p = [re.compile('env1'), re.compile('env2')] self.assertEqual(1, sn.count(filter( - filters.have_prgenv_regexp(p), self.checks))) + filters.have_prgenv(p), self.checks))) p = [re.compile('env3')] - self.assertEqual(2, sn.count(filter(filters.have_prgenv_regexp(p), + self.assertEqual(2, sn.count(filter(filters.have_prgenv(p), self.checks))) p = [re.compile('env4')] - self.assertEqual(1, sn.count(filter(filters.have_prgenv_regexp(p), + self.assertEqual(1, sn.count(filter(filters.have_prgenv(p), self.checks))) p = [re.compile('env1'), re.compile('env3')] self.assertEqual(0, sn.count(filter( - filters.have_prgenv_regexp(p), self.checks))) + filters.have_prgenv(p), self.checks))) @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') From 063272a8a0d64a56164bf4a8a11d84523651f64b Mon Sep 17 00:00:00 2001 From: bignamic Date: Fri, 15 Feb 2019 16:12:18 +0100 Subject: [PATCH 06/12] PrgEnv filtering bug fixing ('*' and no prgenv cases) --- reframe/frontend/check_filters.py | 4 ++-- reframe/frontend/cli.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 06d3207561..5361e9be76 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -35,8 +35,8 @@ def have_prgenv(regexp_prgenv): def _fn(c): if regexp_prgenv: for p in regexp_prgenv: - if(any(p.search(prgenv) for prgenv in c.valid_prog_environs) - is False): + if(any((p.search(prgenv) or prgenv == '*') + for prgenv in c.valid_prog_environs) is False): return False return True else: diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 694393cc5b..1575e2d65b 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -431,10 +431,9 @@ def main(): # Filter checks by prgenv if not options.skip_prgenv_check: - if len(options.prgenv) > 0: - p = [re.compile(regexp) for regexp in options.prgenv] - checks_matched = filter(filters.have_prgenv(p), - checks_matched) + p = [re.compile(regexp) for regexp in options.prgenv] + checks_matched = filter(filters.have_prgenv(p), + checks_matched) # Filter checks by system if not options.skip_system_check: From 1d46730571fb11a817adcb99a61fd952e3516f87 Mon Sep 17 00:00:00 2001 From: bignamic Date: Wed, 20 Feb 2019 15:28:24 +0100 Subject: [PATCH 07/12] Requested changes implemented --- reframe/frontend/check_filters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 5361e9be76..22324c0523 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -8,7 +8,8 @@ def have_name(regexp_names): def _fn(c): for p in regexp_names: if p.search(c.name): - return c.name + return True + return False return _fn @@ -24,7 +25,7 @@ def have_tag(regexp_tags): def _fn(c): if regexp_tags: for p in regexp_tags: - if(any(p.search(tag) for tag in c.tags) is False): + if not any(p.search(tag) for tag in c.tags): return False return True @@ -35,8 +36,7 @@ def have_prgenv(regexp_prgenv): def _fn(c): if regexp_prgenv: for p in regexp_prgenv: - if(any((p.search(prgenv) or prgenv == '*') - for prgenv in c.valid_prog_environs) is False): + if not any(p.search(prgenv) or prgenv == '*' for prgenv in c.valid_prog_environs): return False return True else: From 540a42db0b1d8f00358eacea11e4d690e550cd03 Mon Sep 17 00:00:00 2001 From: bignamic Date: Mon, 11 Mar 2019 15:21:57 +0100 Subject: [PATCH 08/12] new API implementation: regular expressions is now compiled within the filtering functions --- reframe/frontend/check_filters.py | 31 +++++++--------- reframe/frontend/cli.py | 31 ++++++++-------- unittests/test_check_filters.py | 60 +++++++++++-------------------- 3 files changed, 49 insertions(+), 73 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 22324c0523..9dd1e45cbe 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -4,43 +4,36 @@ import reframe.utility.sanity as util -def have_name(regexp_names): +def have_name(patt): + regex = re.compile(patt) def _fn(c): - for p in regexp_names: - if p.search(c.name): - return True - return False + return regex.match(c.name) return _fn -def have_not_name(regexp_names): +def have_not_name(patt): def _fn(c): - return not have_name(regexp_names)(c) + return not have_name(patt)(c) return _fn -def have_tag(regexp_tags): +def have_tag(patt): + regex = re.compile(patt) def _fn(c): - if regexp_tags: - for p in regexp_tags: - if not any(p.search(tag) for tag in c.tags): - return False - return True + return any(regex.match(p) for p in c.tags) return _fn -def have_prgenv(regexp_prgenv): +def have_prgenv(patt): + regex = re.compile(patt) def _fn(c): - if regexp_prgenv: - for p in regexp_prgenv: - if not any(p.search(prgenv) or prgenv == '*' for prgenv in c.valid_prog_environs): - return False + if '*' in c.valid_prog_environs: return True else: - return bool(c.valid_prog_environs) + return any(regex.match(p) for p in c.valid_prog_environs) return _fn diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 62e7b5dc7c..f01005066f 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -1,7 +1,6 @@ import inspect import json import os -import re import socket import sys import traceback @@ -112,7 +111,7 @@ def main(): '-x', '--exclude', action='append', dest='exclude_names', metavar='NAME', default=[], help='Exclude checks with NAME') select_options.add_argument( - '-p', '--prgenv', action='append', default=[], + '-p', '--prgenv', action='append', default=[r'.*'], help='Select tests for PRGENV programming environment only') select_options.add_argument( '--gpu-only', action='store_true', @@ -415,26 +414,30 @@ def main(): raise ReframeError from e # Filter checks by name - p = [re.compile(regexp) for regexp in options.exclude_names] - checks_matched = filter(filters.have_not_name(p), - checks_found) + checks_matched = checks_found + if options.exclude_names: + for name in options.exclude_names: + checks_matched = filter(filters.have_not_name(name), + checks_matched) if options.names: - # TODO: should I merge the input string into a single regexp? - p = [re.compile(regexp) for regexp in options.names] - checks_matched = filter(filters.have_name(p), + if len(options.names) > 1: + options_names = "|".join(options.names) + else: + options_names = options.names[0] + checks_matched = filter(filters.have_name(options_names), checks_matched) # Filter checks by tags - checks_matched = filter(filters.have_tag([ - re.compile(regexp) for regexp in options.tags]), - checks_matched) + for tag in options.tags: + checks_matched = filter(filters.have_tag(tag), + checks_matched) # Filter checks by prgenv if not options.skip_prgenv_check: - p = [re.compile(regexp) for regexp in options.prgenv] - checks_matched = filter(filters.have_prgenv(p), - checks_matched) + for prgenv in options.prgenv: + checks_matched = filter(filters.have_prgenv(prgenv), + checks_matched) # Filter checks by system if not options.skip_system_check: diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 0a0964d73f..8768923f4b 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -40,69 +40,49 @@ def setUp(self): def test_have_name(self): - p = [re.compile('check1')] - self.assertEqual(1, sn.count(filter(filters.have_name(p), + self.assertEqual(1, sn.count(filter(filters.have_name('check1'), self.checks))) - p = [re.compile('check')] - self.assertEqual(3, sn.count(filter(filters.have_name(p), + self.assertEqual(3, sn.count(filter(filters.have_name('check'), self.checks))) - p = [re.compile('.1|.3')] - self.assertEqual(2, sn.count(filter(filters.have_name(p), + self.assertEqual(2, sn.count(filter(filters.have_name('\S*1|\S*3'), self.checks))) - p = [re.compile('Check')] - self.assertEqual(0, sn.count(filter(filters.have_name(p), + self.assertEqual(0, sn.count(filter(filters.have_name('Check'), self.checks))) - p = [re.compile('(?i)Check')] - self.assertEqual(3, sn.count(filter(filters.have_name(p), + self.assertEqual(3, sn.count(filter(filters.have_name('(?i)Check'), self.checks))) - p = [re.compile('check1'), re.compile('(?i)CHECK2')] - self.assertEqual(2, sn.count(filter(filters.have_name(p), + self.assertEqual(2, sn.count(filter(filters.have_name('check1|(?i)CHECK2'), self.checks))) def test_have_not_name(self): - p = [re.compile('check1')] - self.assertEqual(2, sn.count(filter(filters.have_not_name(p), + self.assertEqual(2, sn.count(filter(filters.have_not_name('check1'), self.checks))) - p = [re.compile('check1'), re.compile('check3')] - self.assertEqual(1, sn.count(filter(filters.have_not_name(p), + self.assertEqual(1, sn.count(filter(filters.have_not_name('check1|check3'), self.checks))) - p = [re.compile('check1'), re.compile('check2'), re.compile('check3')] - self.assertEqual(0, sn.count(filter(filters.have_not_name(p), + self.assertEqual(0, sn.count(filter(filters.have_not_name('check1|check2|check3'), self.checks))) - p = [re.compile('Check1')] - self.assertEqual(3, sn.count(filter(filters.have_not_name(p), + self.assertEqual(3, sn.count(filter(filters.have_not_name('Check1'), self.checks))) - p = [re.compile('Check1')] - self.assertEqual(3, sn.count(filter(filters.have_not_name(p), - self.checks))) - p = [re.compile('(?i)Check1')] - self.assertEqual(2, sn.count(filter(filters.have_not_name(p), + self.assertEqual(2, sn.count(filter(filters.have_not_name('(?i)Check1'), self.checks))) def test_have_tags(self): - p = [re.compile('a'), re.compile('c')] - self.assertEqual(1, sn.count(filter(filters.have_tag(p), + self.assertEqual(2, sn.count(filter(filters.have_tag('a|c'), self.checks))) - p = [re.compile('p'), re.compile('q')] - self.assertEqual(0, sn.count(filter(filters.have_tag(p), + self.assertEqual(0, sn.count(filter(filters.have_tag('p|q'), self.checks))) - p = [re.compile('z')] - self.assertEqual(2, sn.count(filter(filters.have_tag(p), + self.assertEqual(2, sn.count(filter(filters.have_tag('z'), self.checks))) + def test_have_prgenv(self): - p = [re.compile('env1'), re.compile('env2')] self.assertEqual(1, sn.count(filter( - filters.have_prgenv(p), self.checks))) - p = [re.compile('env3')] - self.assertEqual(2, sn.count(filter(filters.have_prgenv(p), + filters.have_prgenv('env1|env2'), self.checks))) + self.assertEqual(2, sn.count(filter(filters.have_prgenv('env3'), self.checks))) - p = [re.compile('env4')] - self.assertEqual(1, sn.count(filter(filters.have_prgenv(p), + self.assertEqual(1, sn.count(filter(filters.have_prgenv('env4'), self.checks))) - p = [re.compile('env1'), re.compile('env3')] - self.assertEqual(0, sn.count(filter( - filters.have_prgenv(p), self.checks))) + self.assertEqual(3, sn.count(filter( + filters.have_prgenv('env1|env3'), self.checks))) @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') From 44df731ca140be910ccc9c3f6339eb8ef426eb91 Mon Sep 17 00:00:00 2001 From: bignamic Date: Wed, 13 Mar 2019 15:21:42 +0100 Subject: [PATCH 09/12] Coding style fixes and code refactoring --- reframe/frontend/check_filters.py | 2 +- reframe/frontend/cli.py | 11 ++--- unittests/test_check_filters.py | 77 ++++++++++++------------------- 3 files changed, 34 insertions(+), 56 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index 9dd1e45cbe..fa68993734 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -7,7 +7,7 @@ def have_name(patt): regex = re.compile(patt) def _fn(c): - return regex.match(c.name) + return regex.match(c.name) return _fn diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index f01005066f..8e09f17d97 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -421,17 +421,12 @@ def main(): checks_matched) if options.names: - if len(options.names) > 1: - options_names = "|".join(options.names) - else: - options_names = options.names[0] - checks_matched = filter(filters.have_name(options_names), - checks_matched) + checks_matched = filter(filters.have_name("|".join(options.names)), + checks_matched) # Filter checks by tags for tag in options.tags: - checks_matched = filter(filters.have_tag(tag), - checks_matched) + checks_matched = filter(filters.have_tag(tag), checks_matched) # Filter checks by prgenv if not options.skip_prgenv_check: diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 8768923f4b..31e642a489 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -1,4 +1,3 @@ -import re import unittest import reframe.core.runtime as rt @@ -38,66 +37,50 @@ def setUp(self): 'num_gpus_per_node': 1}) ] + def count_checks(self, filter_fn): + return sn.count(filter(filter_fn, self.checks)) def test_have_name(self): - self.assertEqual(1, sn.count(filter(filters.have_name('check1'), - self.checks))) - self.assertEqual(3, sn.count(filter(filters.have_name('check'), - self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_name('\S*1|\S*3'), - self.checks))) - self.assertEqual(0, sn.count(filter(filters.have_name('Check'), - self.checks))) - self.assertEqual(3, sn.count(filter(filters.have_name('(?i)Check'), - self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_name('check1|(?i)CHECK2'), - self.checks))) + self.assertEqual(1, self.count_checks(filters.have_name('check1'))) + self.assertEqual(3, self.count_checks(filters.have_name('check'))) + self.assertEqual(2, self.count_checks(filters.have_name('\S*1|\S*3'))) + self.assertEqual(0, self.count_checks(filters.have_name('Check'))) + self.assertEqual(3, self.count_checks(filters.have_name('(?i)Check'))) + self.assertEqual(2, self.count_checks(filters.have_name( + 'check1|(?i)CHECK2'))) def test_have_not_name(self): - self.assertEqual(2, sn.count(filter(filters.have_not_name('check1'), - self.checks))) - self.assertEqual(1, sn.count(filter(filters.have_not_name('check1|check3'), - self.checks))) - self.assertEqual(0, sn.count(filter(filters.have_not_name('check1|check2|check3'), - self.checks))) - self.assertEqual(3, sn.count(filter(filters.have_not_name('Check1'), - self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_not_name('(?i)Check1'), - self.checks))) + self.assertEqual(2, self.count_checks(filters.have_not_name('check1'))) + self.assertEqual(1, self.count_checks(filters.have_not_name( + 'check1|check3'))) + self.assertEqual(0, self.count_checks(filters.have_not_name( + 'check1|check2|check3'))) + self.assertEqual(3, self.count_checks(filters.have_not_name('Check1'))) + self.assertEqual(2, self.count_checks(filters.have_not_name( + '(?i)Check1'))) def test_have_tags(self): - self.assertEqual(2, sn.count(filter(filters.have_tag('a|c'), - self.checks))) - self.assertEqual(0, sn.count(filter(filters.have_tag('p|q'), - self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_tag('z'), - self.checks))) - + self.assertEqual(2, self.count_checks(filters.have_tag('a|c'))) + self.assertEqual(0, self.count_checks(filters.have_tag('p|q'))) + self.assertEqual(2, self.count_checks(filters.have_tag('z'))) def test_have_prgenv(self): - self.assertEqual(1, sn.count(filter( - filters.have_prgenv('env1|env2'), self.checks))) - self.assertEqual(2, sn.count(filter(filters.have_prgenv('env3'), - self.checks))) - self.assertEqual(1, sn.count(filter(filters.have_prgenv('env4'), - self.checks))) - self.assertEqual(3, sn.count(filter( - filters.have_prgenv('env1|env3'), self.checks))) - + self.assertEqual(1, self.count_checks(filters.have_prgenv( + 'env1|env2'))) + self.assertEqual(2, self.count_checks(filters.have_prgenv('env3'))) + self.assertEqual(1, self.count_checks(filters.have_prgenv('env4'))) + self.assertEqual(3, self.count_checks(filters.have_prgenv( + 'env1|env3'))) @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') def test_partition(self): p = rt.runtime().system.partition('gpu') - self.assertEqual(2, sn.count(filter(filters.have_partition([p]), - self.checks))) + self.assertEqual(2, self.count_checks(filters.have_partition([p]))) p = rt.runtime().system.partition('login') - self.assertEqual(0, sn.count(filter(filters.have_partition([p]), - self.checks))) + self.assertEqual(0, self.count_checks(filters.have_partition([p]))) def test_have_gpu_only(self): - self.assertEqual(2, sn.count(filter(filters.have_gpu_only(), - self.checks))) + self.assertEqual(2, self.count_checks(filters.have_gpu_only())) def test_have_cpu_only(self): - self.assertEqual(1, sn.count(filter(filters.have_cpu_only(), - self.checks))) + self.assertEqual(1, self.count_checks(filters.have_cpu_only())) From 6a19630375b9f9703a64b1cf9b1eb2d5e143650c Mon Sep 17 00:00:00 2001 From: bignamic Date: Thu, 14 Mar 2019 11:18:06 +0100 Subject: [PATCH 10/12] Programming environment wildcard support removed --- reframe/core/pipeline.py | 14 +++++++++----- unittests/test_pipeline.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 1c0424af37..f19b17082d 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -6,7 +6,6 @@ 'RunOnlyRegressionTest', 'CompileOnlyRegressionTest'] -import fnmatch import inspect import itertools import os @@ -66,12 +65,18 @@ class RegressionTest: #: List of programming environments supported by this test. #: + #: If ``*`` is in the list then all programming environments are supported + #: by this test. + #: #: :type: :class:`List[str]` #: :default: ``[]`` #: #: .. note:: #: .. versionchanged:: 2.12 #: Programming environments can now be specified using wildcards. + #: + #: .. versionchanged:: 2.17 + #: Support for wildcards is dropped. valid_prog_environs = fields.TypedField('valid_prog_environs', typ.List[str]) @@ -786,11 +791,10 @@ def supports_system(self, partition_name): return partition_name in self.valid_systems def supports_environ(self, env_name): - for env in self.valid_prog_environs: - if fnmatch.fnmatch(env_name, env): - return True + if '*' in self.valid_prog_environs: + return True - return False + return env_name in self.valid_prog_environs def is_local(self): """Check if the test will execute locally. diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index b23a2b4050..c883c0e78d 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -253,8 +253,8 @@ def test_supports_environ(self): self.assertTrue(test.supports_environ('*')) test.valid_prog_environs = ['PrgEnv-foo-*'] - self.assertTrue(test.supports_environ('PrgEnv-foo-version1')) - self.assertTrue(test.supports_environ('PrgEnv-foo-version2')) + self.assertFalse(test.supports_environ('PrgEnv-foo-version1')) + self.assertFalse(test.supports_environ('PrgEnv-foo-version2')) self.assertFalse(test.supports_environ('PrgEnv-boo-version1')) self.assertFalse(test.supports_environ('Prgenv-foo-version1')) From 4640a49c12d5603d5aa908caf6ee06bd90edc6f0 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 14 Mar 2019 13:03:12 +0100 Subject: [PATCH 11/12] Fine tune coding style Also - Remove unit tests for wildcards in `valid_prog_environs`. --- reframe/frontend/check_filters.py | 3 +++ reframe/frontend/cli.py | 2 +- unittests/test_check_filters.py | 30 ++++++++++++++++++------------ unittests/test_pipeline.py | 6 ------ 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/reframe/frontend/check_filters.py b/reframe/frontend/check_filters.py index fa68993734..a16bce3f9b 100644 --- a/reframe/frontend/check_filters.py +++ b/reframe/frontend/check_filters.py @@ -6,6 +6,7 @@ def have_name(patt): regex = re.compile(patt) + def _fn(c): return regex.match(c.name) @@ -21,6 +22,7 @@ def _fn(c): def have_tag(patt): regex = re.compile(patt) + def _fn(c): return any(regex.match(p) for p in c.tags) @@ -29,6 +31,7 @@ def _fn(c): def have_prgenv(patt): regex = re.compile(patt) + def _fn(c): if '*' in c.valid_prog_environs: return True diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 8e09f17d97..3932ab1ed2 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -421,7 +421,7 @@ def main(): checks_matched) if options.names: - checks_matched = filter(filters.have_name("|".join(options.names)), + checks_matched = filter(filters.have_name('|'.join(options.names)), checks_matched) # Filter checks by tags diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 31e642a489..2055186172 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -46,18 +46,22 @@ def test_have_name(self): self.assertEqual(2, self.count_checks(filters.have_name('\S*1|\S*3'))) self.assertEqual(0, self.count_checks(filters.have_name('Check'))) self.assertEqual(3, self.count_checks(filters.have_name('(?i)Check'))) - self.assertEqual(2, self.count_checks(filters.have_name( - 'check1|(?i)CHECK2'))) + self.assertEqual( + 2, self.count_checks(filters.have_name('check1|(?i)CHECK2')) + ) def test_have_not_name(self): self.assertEqual(2, self.count_checks(filters.have_not_name('check1'))) - self.assertEqual(1, self.count_checks(filters.have_not_name( - 'check1|check3'))) - self.assertEqual(0, self.count_checks(filters.have_not_name( - 'check1|check2|check3'))) + self.assertEqual( + 1, self.count_checks(filters.have_not_name('check1|check3')) + ) + self.assertEqual( + 0, self.count_checks(filters.have_not_name('check1|check2|check3')) + ) self.assertEqual(3, self.count_checks(filters.have_not_name('Check1'))) - self.assertEqual(2, self.count_checks(filters.have_not_name( - '(?i)Check1'))) + self.assertEqual( + 2, self.count_checks(filters.have_not_name('(?i)Check1')) + ) def test_have_tags(self): self.assertEqual(2, self.count_checks(filters.have_tag('a|c'))) @@ -65,12 +69,14 @@ def test_have_tags(self): self.assertEqual(2, self.count_checks(filters.have_tag('z'))) def test_have_prgenv(self): - self.assertEqual(1, self.count_checks(filters.have_prgenv( - 'env1|env2'))) + self.assertEqual( + 1, self.count_checks(filters.have_prgenv('env1|env2')) + ) self.assertEqual(2, self.count_checks(filters.have_prgenv('env3'))) self.assertEqual(1, self.count_checks(filters.have_prgenv('env4'))) - self.assertEqual(3, self.count_checks(filters.have_prgenv( - 'env1|env3'))) + self.assertEqual( + 3, self.count_checks(filters.have_prgenv('env1|env3')) + ) @rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'testsys') def test_partition(self): diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index c883c0e78d..5605bf4674 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -252,12 +252,6 @@ def test_supports_environ(self): self.assertTrue(test.supports_environ('foo-env')) self.assertTrue(test.supports_environ('*')) - test.valid_prog_environs = ['PrgEnv-foo-*'] - self.assertFalse(test.supports_environ('PrgEnv-foo-version1')) - self.assertFalse(test.supports_environ('PrgEnv-foo-version2')) - self.assertFalse(test.supports_environ('PrgEnv-boo-version1')) - self.assertFalse(test.supports_environ('Prgenv-foo-version1')) - def test_sourcesdir_none(self): test = RegressionTest('hellocheck', 'unittests/resources/checks') test.sourcesdir = None From 2564ab082528c229bca56ad7c75573c9c6df140c Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 14 Mar 2019 15:40:28 +0100 Subject: [PATCH 12/12] Use raw string in regex Co-Authored-By: ChristopherBignamini --- unittests/test_check_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/test_check_filters.py b/unittests/test_check_filters.py index 2055186172..2f3b4920f2 100644 --- a/unittests/test_check_filters.py +++ b/unittests/test_check_filters.py @@ -43,7 +43,7 @@ def count_checks(self, filter_fn): def test_have_name(self): self.assertEqual(1, self.count_checks(filters.have_name('check1'))) self.assertEqual(3, self.count_checks(filters.have_name('check'))) - self.assertEqual(2, self.count_checks(filters.have_name('\S*1|\S*3'))) + self.assertEqual(2, self.count_checks(filters.have_name(r'\S*1|\S*3'))) self.assertEqual(0, self.count_checks(filters.have_name('Check'))) self.assertEqual(3, self.count_checks(filters.have_name('(?i)Check'))) self.assertEqual(