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
6 changes: 5 additions & 1 deletion reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ class CheckFieldFormatter(logging.Formatter):
# NOTE: This formatter will work only for the '%' style
def __init__(self, fmt=None, datefmt=None, perffmt=None,
ignore_keys=None, style='%'):
super().__init__(fmt, datefmt, style)
if sys.version_info[:2] <= (3, 7):
super().__init__(fmt, datefmt, style)
else:
super().__init__(fmt, datefmt, style,
validate=(fmt != '%(check_#ALL)s'))

self.__fmt = fmt
self.__fmtperf = perffmt[:-1] if perffmt else ''
Expand Down
12 changes: 9 additions & 3 deletions unittests/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,9 +1345,14 @@ def test_perf_logging_lazy(make_runner, make_exec_ctx, lazy_perf_test,
assert os.path.exists(logfile)


@pytest.fixture(params=['%(check_result)s|%(check_#ALL)s', '%(check_#ALL)s'])
def perflog_fmt(request):
return request.param


def test_perf_logging_all_attrs(make_runner, make_exec_ctx, perf_test,
config_perflog, tmp_path):
make_exec_ctx(config_perflog(fmt='%(check_result)s|%(check_#ALL)s'))
config_perflog, tmp_path, perflog_fmt):
make_exec_ctx(config_perflog(fmt=perflog_fmt))
logging.configure_logging(rt.runtime().site_config)
runner = make_runner()
testcases = executors.generate_testcases([perf_test])
Expand All @@ -1359,7 +1364,8 @@ def test_perf_logging_all_attrs(make_runner, make_exec_ctx, perf_test,
header = fp.readline()

loggable_attrs = type(perf_test).loggable_attrs()
assert len(header.split('|')) == len(loggable_attrs) + 1
assert (len(header.split('|')) ==
len(loggable_attrs) + (perflog_fmt != '%(check_#ALL)s'))


def test_perf_logging_custom_vars(make_runner, make_exec_ctx,
Expand Down