Skip to content

Commit

Permalink
Merge pull request #2834 from vkarak/feat/latest-report
Browse files Browse the repository at this point in the history
[feat] Add a symlink to the latest run report
  • Loading branch information
vkarak committed Mar 28, 2023
2 parents 3cc0275 + d011381 commit 9de010f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause

import functools
import inspect
import itertools
import json
Expand Down Expand Up @@ -1369,6 +1370,23 @@ def module_unuse(*paths):
printer.warning(
f'failed to generate report in {report_file!r}: {e}'
)
else:
# Add a symlink to the latest report
with osext.change_dir(basedir):
link_name = 'latest.json'
create_symlink = functools.partial(
os.symlink, os.path.basename(report_file), link_name
)
if not os.path.exists(link_name):
create_symlink()
else:
if os.path.islink(link_name):
os.remove(link_name)
create_symlink()
else:
printer.warning('could not create a symlink '
'to the latest report file; '
'path exists and is not a symlink')

# Generate the junit xml report for this session
junit_report_file = rt.get_option('general/0/report_junit')
Expand Down
3 changes: 3 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def test_report_file_with_sessionid(run_reframe, tmp_path, run_action):
)
assert returncode == 0
assert os.path.exists(tmp_path / 'rfm-report-0.json')
assert os.readlink(tmp_path / 'latest.json') == 'rfm-report-0.json'


def test_report_ends_with_newline(run_reframe, tmp_path, run_action):
Expand All @@ -238,6 +239,8 @@ def test_report_ends_with_newline(run_reframe, tmp_path, run_action):
with open(tmp_path / 'rfm-report.json') as fp:
assert fp.read()[-1] == '\n'

assert os.readlink(tmp_path / 'latest.json') == 'rfm-report.json'


def test_check_submit_success(run_reframe, remote_exec_ctx, run_action):
# This test will run on the auto-detected system
Expand Down

0 comments on commit 9de010f

Please sign in to comment.