Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.python.org/3/library/re.html>`__;
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.
Expand Down
8 changes: 8 additions & 0 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down Expand Up @@ -809,6 +814,9 @@ def print_infoline(param, value):
)

# Filter test cases by 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)

Expand Down
7 changes: 7 additions & 0 deletions reframe/frontend/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions unittests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down