From 550ee6193a7d790f680103ffa35145309e094da8 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 22 Apr 2021 17:04:53 +0200 Subject: [PATCH 1/3] Add '--list-tags' cli action Signed-off-by: Theofilos Manitaras --- docs/manpage.rst | 8 ++++++++ reframe/frontend/cli.py | 16 ++++++++++++++++ unittests/test_cli.py | 17 ++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/manpage.rst b/docs/manpage.rst index b759cb1ed0..81553980e4 100644 --- a/docs/manpage.rst +++ b/docs/manpage.rst @@ -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. diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index e107ec5c67..b0026ab874 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -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: ' @@ -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' + ) action_options.add_argument( '-r', '--run', action='store_true', help='Run the selected checks' @@ -803,6 +815,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]') diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 7818eded1c..78f1c65a9d 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -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'] @@ -499,7 +501,7 @@ def test_timestamp_option(run_reframe): def test_list_empty_prgenvs_check_and_options(run_reframe): returncode, stdout, _ = run_reframe( - checkpath=['unittests/resources/checks/frontend_checks.py'], + checkpath=['unittests/resources/checks/hellocheck.py'], action='list', environs=[], more_options=['-n', 'NoPrgEnvCheck'], @@ -539,6 +541,19 @@ def test_list_with_details(run_reframe): assert 'Traceback' not in stderr 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( From ca8fe4a9cf4e9547544bd84b89e8d0b273e81efb Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 22 Apr 2021 17:07:53 +0200 Subject: [PATCH 2/3] PEP8 fix --- unittests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 78f1c65a9d..0d83609843 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -541,6 +541,7 @@ def test_list_with_details(run_reframe): assert 'Traceback' not in stderr assert returncode == 0 + def test_list_tags(run_reframe): returncode, stdout, stderr = run_reframe( checkpath=['unittests/resources/checks/hellocheck.py', @@ -554,7 +555,6 @@ def test_list_tags(run_reframe): assert returncode == 0 - def test_filtering_multiple_criteria(run_reframe): returncode, stdout, stderr = run_reframe( checkpath=['unittests/resources/checks'], From 866d4e55f3caa0cd1beabfb2e919a07dbe6e0073 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 22 Apr 2021 17:57:25 +0200 Subject: [PATCH 3/3] Address PR comments --- reframe/frontend/cli.py | 3 ++- unittests/test_cli.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index b0026ab874..551143d6ae 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -279,7 +279,7 @@ def main(): ) action_options.add_argument( '--list-tags', action='store_true', - help='List the unique tags found in the selected tests' + help='List the unique tags found in the selected tests and exit' ) action_options.add_argument( '-r', '--run', action='store_true', @@ -835,6 +835,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) diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 0d83609843..b11605dead 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -501,7 +501,7 @@ def test_timestamp_option(run_reframe): def test_list_empty_prgenvs_check_and_options(run_reframe): returncode, stdout, _ = run_reframe( - checkpath=['unittests/resources/checks/hellocheck.py'], + checkpath=['unittests/resources/checks/frontend_checks.py'], action='list', environs=[], more_options=['-n', 'NoPrgEnvCheck'],