Skip to content

Commit 4d8753a

Browse files
authored
Merge pull request #3202 from vkarak/bugfix/check-all-failure
[bugfix] Fix logging crash when log format is `%(check_#ALL)s`
2 parents 0bee29c + b0cbaa9 commit 4d8753a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

reframe/core/logging.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ 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)
304+
if sys.version_info[:2] <= (3, 7):
305+
super().__init__(fmt, datefmt, style)
306+
else:
307+
super().__init__(fmt, datefmt, style,
308+
validate=(fmt != '%(check_#ALL)s'))
305309

306310
self.__fmt = fmt
307311
self.__fmtperf = perffmt[:-1] if perffmt else ''

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)