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
8 changes: 8 additions & 0 deletions docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ An action must always be specified.
List selected tests providing detailed information per test.


.. option:: --list-tags

List the unique tags of the selected tests.
The tags are printed in alphabetical order.

.. versionadded:: 3.6.0


.. option:: -r, --run

Execute the selected tests.
Expand Down
17 changes: 17 additions & 0 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ def list_checks(testcases, printer, detailed=False):
printer.info(f'Found {len(checks)} check(s)\n')


def list_tags(testcases, printer):
printer.info('[List of unique tags]')
tags = set()
tags = tags.union(*(t.check.tags for t in testcases))
printer.info(', '.join(f'{t!r}' for t in sorted(tags)))
printer.info(f'Found {len(tags)} tag(s)\n')


def logfiles_message():
log_files = logging.log_files()
msg = 'Log file(s) saved in: '
Expand Down Expand Up @@ -269,6 +277,10 @@ def main():
'-L', '--list-detailed', action='store_true',
help='List the selected checks providing details for each test'
)
action_options.add_argument(
'--list-tags', action='store_true',
help='List the unique tags found in the selected tests and exit'
)
action_options.add_argument(
'-r', '--run', action='store_true',
help='Run the selected checks'
Expand Down Expand Up @@ -810,6 +822,10 @@ def _case_failed(t):
list_checks(testcases, printer, options.list_detailed)
sys.exit(0)

if options.list_tags:
list_tags(testcases, printer)
sys.exit(0)

if options.ci_generate:
list_checks(testcases, printer)
printer.info('[Generate CI]')
Expand All @@ -826,6 +842,7 @@ def _case_failed(t):
printer.error("No action option specified. Available options:\n"
" - `-l'/`-L' for listing\n"
" - `-r' for running\n"
" - `--list-tags' for listing unique test tags\n"
" - `--ci-generate' for generating a CI pipeline\n"
f"Try `{argparser.prog} -h' for more options.")
sys.exit(1)
Expand Down
15 changes: 15 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def _run_reframe(system='generic:default',
argv += ['-l']
elif action == 'list_detailed':
argv += ['-L']
elif action == 'list_tags':
argv += ['--list-tags']
elif action == 'help':
argv += ['-h']

Expand Down Expand Up @@ -540,6 +542,19 @@ def test_list_with_details(run_reframe):
assert returncode == 0


def test_list_tags(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/hellocheck.py',
'unittests/resources/checks/hellocheck_make.py'],
action='list_tags'
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert 'Found 2 tag(s)' in stdout
assert "'bar', 'foo'" in stdout
assert returncode == 0


def test_filtering_multiple_criteria(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks'],
Expand Down