Skip to content

Commit cd924f8

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2414 from teojgo/bugfix/print_null_config_default
[bugfix] Fix `--show-config` for `null` config options
2 parents fd59db9 + a7b4357 commit cd924f8

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

reframe/core/runtime.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,17 @@ def modules_system(self):
162162
'''
163163
return self._system.modules_system
164164

165-
def get_option(self, option):
165+
def get_option(self, option, default=None):
166166
'''Get a configuration option.
167167
168168
:arg option: The option to be retrieved.
169+
:arg default: The value to return if ``option`` cannot be retrieved.
169170
:returns: The value of the option.
171+
172+
.. versionchanged:: 3.11.0
173+
Add ``default`` named argument.
170174
'''
171-
return self._site_config.get(option)
175+
return self._site_config.get(option, default=default)
172176

173177

174178
# Global resources for the current host

reframe/frontend/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,11 @@ def restrict_logging():
772772
if config_param == 'all':
773773
printer.info(str(rt.site_config))
774774
else:
775-
value = rt.get_option(config_param)
776-
if value is None:
775+
# Create a unique value to differentiate between configuration
776+
# parameters with value `None` and invalid ones
777+
default = {'token'}
778+
value = rt.get_option(config_param, default)
779+
if value is default:
777780
printer.error(
778781
f'no such configuration parameter found: {config_param}'
779782
)

reframe/schemas/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@
571571
"systems/partitions/max_jobs": 8,
572572
"systems/partitions/prepare_cmds": [],
573573
"systems/partitions/processor": {},
574+
"systems/partitions/time_limit": null,
574575
"systems/partitions/devices": [],
575576
"systems/partitions/extras": {}
576577
}

unittests/test_cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,17 @@ def test_show_config_unknown_param(run_reframe):
620620
assert returncode == 0
621621

622622

623+
def test_show_config_null_param(run_reframe):
624+
returncode, stdout, stderr = run_reframe(
625+
more_options=['--show-config=general/report_junit'],
626+
system='testsys'
627+
)
628+
assert 'null' in stdout
629+
assert 'Traceback' not in stdout
630+
assert 'Traceback' not in stderr
631+
assert returncode == 0
632+
633+
623634
def test_verbosity(run_reframe):
624635
returncode, stdout, stderr = run_reframe(
625636
more_options=['-vvvvv'],

0 commit comments

Comments
 (0)