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
8 changes: 6 additions & 2 deletions reframe/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,17 @@ def modules_system(self):
'''
return self._system.modules_system

def get_option(self, option):
def get_option(self, option, default=None):
'''Get a configuration option.

:arg option: The option to be retrieved.
:arg default: The value to return if ``option`` cannot be retrieved.
:returns: The value of the option.

.. versionchanged:: 3.11.0
Add ``default`` named argument.
'''
return self._site_config.get(option)
return self._site_config.get(option, default=default)


# Global resources for the current host
Expand Down
7 changes: 5 additions & 2 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,11 @@ def restrict_logging():
if config_param == 'all':
printer.info(str(rt.site_config))
else:
value = rt.get_option(config_param)
if value is None:
# Create a unique value to differentiate between configuration
# parameters with value `None` and invalid ones
default = {'token'}
value = rt.get_option(config_param, default)
if value is default:
printer.error(
f'no such configuration parameter found: {config_param}'
)
Expand Down
1 change: 1 addition & 0 deletions reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
"systems/partitions/max_jobs": 8,
"systems/partitions/prepare_cmds": [],
"systems/partitions/processor": {},
"systems/partitions/time_limit": null,
"systems/partitions/devices": [],
"systems/partitions/extras": {}
}
Expand Down
11 changes: 11 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,17 @@ def test_show_config_unknown_param(run_reframe):
assert returncode == 0


def test_show_config_null_param(run_reframe):
returncode, stdout, stderr = run_reframe(
more_options=['--show-config=general/report_junit'],
system='testsys'
)
assert 'null' in stdout
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert returncode == 0


def test_verbosity(run_reframe):
returncode, stdout, stderr = run_reframe(
more_options=['-vvvvv'],
Expand Down