Skip to content

Commit

Permalink
Merge pull request #2931 from vkarak/feat/default-timestamp
Browse files Browse the repository at this point in the history
[feat] Update default `--timestamp` format
  • Loading branch information
vkarak committed Jun 21, 2023
2 parents 37d33d8 + c9f30ce commit ea2c8a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions reframe/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import os
import functools
from datetime import datetime
import time

import reframe.core.config as config
import reframe.utility.osext as osext
Expand All @@ -31,7 +31,7 @@ def __init__(self, site_config):
self._site_config = site_config
self._system = System.create(site_config)
self._current_run = 0
self._timestamp = datetime.now()
self._timestamp = time.localtime()

def _makedir(self, *dirs, wipeout=False):
ret = os.path.join(*dirs)
Expand Down Expand Up @@ -111,7 +111,7 @@ def perflogdir(self):
@property
def timestamp(self):
timefmt = self.site_config.get('general/0/timestamp_dirs')
return self._timestamp.strftime(timefmt)
return time.strftime(timefmt, self._timestamp)

@property
def output_prefix(self):
Expand Down
2 changes: 1 addition & 1 deletion reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def main():
envvar='RFM_SAVE_LOG_FILES', configvar='general/save_log_files'
)
output_options.add_argument(
'--timestamp', action='store', nargs='?', const='%FT%T',
'--timestamp', action='store', nargs='?', const='%y%m%dT%H%M%S%z',
metavar='TIMEFMT',
help=('Append a timestamp to the output and stage directory prefixes '
'(default: "%%FT%%T")'),
Expand Down
7 changes: 5 additions & 2 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,17 @@ def test_timestamp_option(run_reframe):


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

matches = re.findall(
r'(stage|output) directory: .*\/(\d{6}T\d{6}\+\d{4})', stdout
)
assert len(matches) == 2


def test_list_empty_prgenvs_check_and_options(run_reframe):
Expand Down

0 comments on commit ea2c8a3

Please sign in to comment.