Skip to content

Commit 5383200

Browse files
committed
Fix logging crash when log format is %(check_#ALL)s
1 parent b1524a2 commit 5383200

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

reframe/core/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ class CheckFieldFormatter(logging.Formatter):
301301
# NOTE: This formatter will work only for the '%' style
302302
def __init__(self, fmt=None, datefmt=None, perffmt=None,
303303
ignore_keys=None, style='%'):
304-
super().__init__(fmt, datefmt, style)
305-
304+
super().__init__(fmt, datefmt, style,
305+
validate=(fmt != '%(check_#ALL)s'))
306306
self.__fmt = fmt
307307
self.__fmtperf = perffmt[:-1] if perffmt else ''
308308
self.__specs = re.findall(r'\%\((\S+?)\)s', fmt)

unittests/test_policies.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,14 @@ def test_perf_logging_lazy(make_runner, make_exec_ctx, lazy_perf_test,
13451345
assert os.path.exists(logfile)
13461346

13471347

1348+
@pytest.fixture(params=['%(check_result)s|%(check_#ALL)s', '%(check_#ALL)s'])
1349+
def perflog_fmt(request):
1350+
return request.param
1351+
1352+
13481353
def test_perf_logging_all_attrs(make_runner, make_exec_ctx, perf_test,
1349-
config_perflog, tmp_path):
1350-
make_exec_ctx(config_perflog(fmt='%(check_result)s|%(check_#ALL)s'))
1354+
config_perflog, tmp_path, perflog_fmt):
1355+
make_exec_ctx(config_perflog(fmt=perflog_fmt))
13511356
logging.configure_logging(rt.runtime().site_config)
13521357
runner = make_runner()
13531358
testcases = executors.generate_testcases([perf_test])
@@ -1359,7 +1364,8 @@ def test_perf_logging_all_attrs(make_runner, make_exec_ctx, perf_test,
13591364
header = fp.readline()
13601365

13611366
loggable_attrs = type(perf_test).loggable_attrs()
1362-
assert len(header.split('|')) == len(loggable_attrs) + 1
1367+
assert (len(header.split('|')) ==
1368+
len(loggable_attrs) + (perflog_fmt != '%(check_#ALL)s'))
13631369

13641370

13651371
def test_perf_logging_custom_vars(make_runner, make_exec_ctx,

0 commit comments

Comments
 (0)