diff --git a/reframe/frontend/argparse.py b/reframe/frontend/argparse.py index 3f1fb8f810..6b8087768a 100644 --- a/reframe/frontend/argparse.py +++ b/reframe/frontend/argparse.py @@ -184,8 +184,7 @@ def add_argument(self, *flags, **kwargs): kwargs['dest'] = opt_name # Convert 'store_true' and 'store_false' actions to their - # 'store_const' equivalents, because they otherwise imply imply a - # default + # 'store_const' equivalents, because they otherwise imply a default action = kwargs.get('action', None) if action == 'store_true' or action == 'store_false': kwargs['action'] = 'store_const' diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 40d049b9b1..3072f1e7c4 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -217,7 +217,8 @@ def main(): envvar='RFM_SAVE_LOG_FILES', configvar='general/save_log_files' ) output_options.add_argument( - '--timestamp', action='store', nargs='?', const='', metavar='TIMEFMT', + '--timestamp', action='store', nargs='?', const='%FT%T', + metavar='TIMEFMT', help=('Append a timestamp to the output and stage directory prefixes ' '(default: "%%FT%%T")'), envvar='RFM_TIMESTAMP_DIRS', configvar='general/timestamp_dirs' diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 48abab4af3..d57520afc3 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -11,6 +11,7 @@ import pytest import re import sys +import time import reframe.core.environments as env import reframe.frontend.runreport as runreport @@ -474,9 +475,7 @@ def test_execution_modes(run_reframe): def test_timestamp_option(run_reframe): - from datetime import datetime - - timefmt = datetime.now().strftime('xxx_%F') + timefmt = time.strftime('xxx_%F') returncode, stdout, _ = run_reframe( checkpath=['unittests/resources/checks'], action='list', @@ -486,6 +485,17 @@ def test_timestamp_option(run_reframe): assert timefmt in stdout +def test_timestamp_option_default(run_reframe): + timefmt_date_part = time.strftime('%FT') + returncode, stdout, _ = run_reframe( + checkpath=['unittests/resources/checks'], + action='list', + more_options=['-R', '--timestamp'] + ) + assert returncode == 0 + assert timefmt_date_part in stdout + + def test_list_empty_prgenvs_check_and_options(run_reframe): returncode, stdout, _ = run_reframe( checkpath=['unittests/resources/checks/frontend_checks.py'],