From 11ae0dc152a674425d8d885898f63c7172507c37 Mon Sep 17 00:00:00 2001 From: rafael Date: Fri, 15 Oct 2021 12:50:25 +0200 Subject: [PATCH 1/4] add support for excluding checks by tags --- reframe/frontend/cli.py | 9 +++++++++ reframe/frontend/filters.py | 7 +++++++ unittests/test_filters.py | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 4ea291c630..4e8c04101b 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -276,6 +276,11 @@ def main(): metavar='PATTERN', default=[], help='Exclude checks whose name matches PATTERN' ) + select_options.add_argument( + '--exclude-tags', action='append', dest='exclude_tags', + metavar='PATTERN', default=[], + help='Exclude checks whose tag matches PATTERN' + ) # Action options action_options.add_argument( @@ -803,6 +808,10 @@ def print_infoline(param, value): ) # Filter test cases by tags + if options.exclude_tags: + for tag in options.exclude_tags: + testcases = filter(filters.have_not_tag(tag), testcases) + for tag in options.tags: testcases = filter(filters.have_tag(tag), testcases) diff --git a/reframe/frontend/filters.py b/reframe/frontend/filters.py index 3584e3d276..f8b6e5990d 100644 --- a/reframe/frontend/filters.py +++ b/reframe/frontend/filters.py @@ -40,6 +40,13 @@ def _fn(case): return _fn +def have_not_tag(patt): + def _fn(case): + return not have_tag(patt)(case) + + return _fn + + def have_gpu_only(): def _fn(case): return case.check.num_gpus_per_node > 0 diff --git a/unittests/test_filters.py b/unittests/test_filters.py index 7f942385b3..be1f2fba1c 100644 --- a/unittests/test_filters.py +++ b/unittests/test_filters.py @@ -76,6 +76,12 @@ def test_have_tags(sample_cases): assert 2 == count_checks(filters.have_tag('z'), sample_cases) +def test_have_not_tags(sample_cases): + assert 1 == count_checks(filters.have_not_tag('a|c'), sample_cases) + assert 3 == count_checks(filters.have_not_tag('p|q'), sample_cases) + assert 1 == count_checks(filters.have_not_tag('z'), sample_cases) + + def test_have_gpu_only(sample_cases): assert 2 == count_checks(filters.have_gpu_only(), sample_cases) From 3df4b0d187b10784c1a3f4472b118fb83715dc04 Mon Sep 17 00:00:00 2001 From: rafael Date: Mon, 25 Oct 2021 10:34:55 +0200 Subject: [PATCH 2/4] fix comments --- reframe/frontend/cli.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 4e8c04101b..46d8587ce7 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -277,7 +277,7 @@ def main(): help='Exclude checks whose name matches PATTERN' ) select_options.add_argument( - '--exclude-tags', action='append', dest='exclude_tags', + '-T', '--exclude-tags', action='append', dest='exclude_tags', metavar='PATTERN', default=[], help='Exclude checks whose tag matches PATTERN' ) @@ -808,9 +808,8 @@ def print_infoline(param, value): ) # Filter test cases by tags - if options.exclude_tags: - for tag in options.exclude_tags: - testcases = filter(filters.have_not_tag(tag), testcases) + for tag in options.exclude_tags: + testcases = filter(filters.have_not_tag(tag), testcases) for tag in options.tags: testcases = filter(filters.have_tag(tag), testcases) From 256020dd1f7985440e4a3c160647729a0163ef84 Mon Sep 17 00:00:00 2001 From: rafael Date: Mon, 25 Oct 2021 13:41:44 +0200 Subject: [PATCH 3/4] add exclude-tags to manpage --- docs/manpage.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/manpage.rst b/docs/manpage.rst index 5cb1a9ece4..30aebc5fc3 100644 --- a/docs/manpage.rst +++ b/docs/manpage.rst @@ -138,6 +138,14 @@ This happens recursively so that if test ``T1`` depends on ``T2`` and ``T2`` dep This option may be specified multiple times, in which case tests with *any* of the specified names will be excluded: ``-x NAME1 -x NAME2`` is therefore equivalent to ``-x 'NAME1|NAME2'``. +.. option:: -T, --exclude-tags=TAGS + + Exclude tests by tags. + ``TAGS`` is interpreted as a `Python Regular Expression `__; + any test with tags matching ``TAGS`` will be excluded. + + This option may be specified multiple times, in which case tests with *any* of the specified tags will be excluded: + ``-T TAG1 -T TAG2`` is therefore equivalent to ``-x 'TAG1|TAG2'``. ------------ Test actions From fcc864d72775080fcfdbac4c880cd6c8e9f912ca Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Mon, 25 Oct 2021 23:36:39 +0200 Subject: [PATCH 4/4] Minor changes and style adjustments. --- docs/manpage.rst | 18 ++++++++++-------- reframe/frontend/cli.py | 10 +++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/manpage.rst b/docs/manpage.rst index 30aebc5fc3..800369fd87 100644 --- a/docs/manpage.rst +++ b/docs/manpage.rst @@ -120,6 +120,16 @@ This happens recursively so that if test ``T1`` depends on ``T2`` and ``T2`` dep Do not filter tests against the selected system. +.. option:: -T, --exclude-tag=TAG + + Exclude tests by tags. + + ``TAG`` is interpreted as a `Python Regular Expression `__; + any test with tags matching ``TAG`` will be excluded. + + This option may be specified multiple times, in which case tests with *any* of the specified tags will be excluded: + ``-T TAG1 -T TAG2`` is therefore equivalent to ``-T 'TAG1|TAG2'``. + .. option:: -t, --tag=TAG Filter tests by tag. @@ -138,14 +148,6 @@ This happens recursively so that if test ``T1`` depends on ``T2`` and ``T2`` dep This option may be specified multiple times, in which case tests with *any* of the specified names will be excluded: ``-x NAME1 -x NAME2`` is therefore equivalent to ``-x 'NAME1|NAME2'``. -.. option:: -T, --exclude-tags=TAGS - - Exclude tests by tags. - ``TAGS`` is interpreted as a `Python Regular Expression `__; - any test with tags matching ``TAGS`` will be excluded. - - This option may be specified multiple times, in which case tests with *any* of the specified tags will be excluded: - ``-T TAG1 -T TAG2`` is therefore equivalent to ``-x 'TAG1|TAG2'``. ------------ Test actions diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 46d8587ce7..e562a59f75 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -266,6 +266,11 @@ def main(): help=('Select checks with at least one ' 'programming environment matching PATTERN') ) + select_options.add_argument( + '-T', '--exclude-tag', action='append', dest='exclude_tags', + metavar='PATTERN', default=[], + help='Exclude checks whose tag matches PATTERN' + ) select_options.add_argument( '-t', '--tag', action='append', dest='tags', metavar='PATTERN', default=[], @@ -276,11 +281,6 @@ def main(): metavar='PATTERN', default=[], help='Exclude checks whose name matches PATTERN' ) - select_options.add_argument( - '-T', '--exclude-tags', action='append', dest='exclude_tags', - metavar='PATTERN', default=[], - help='Exclude checks whose tag matches PATTERN' - ) # Action options action_options.add_argument(