From 96a2f806c8772e81adad84a2b54a2ae9057af5ec Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 2 Feb 2022 18:43:10 +0100 Subject: [PATCH 1/3] Fix `--show-config` for `null` config options --- reframe/core/runtime.py | 8 ++++++-- reframe/frontend/cli.py | 7 +++++-- reframe/schemas/config.json | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/reframe/core/runtime.py b/reframe/core/runtime.py index 78f2e92b22..eb4b13edd5 100644 --- a/reframe/core/runtime.py +++ b/reframe/core/runtime.py @@ -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 diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index f1c83fbfc7..efb1119fb2 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -769,8 +769,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 check against configuration parameters with + # value `None` and invalid ones + default = time.time() + value = rt.get_option(config_param, default) + if value == default: printer.error( f'no such configuration parameter found: {config_param}' ) diff --git a/reframe/schemas/config.json b/reframe/schemas/config.json index 045267f08b..634028346c 100644 --- a/reframe/schemas/config.json +++ b/reframe/schemas/config.json @@ -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": {} } From 83d134e28befbe03283cda766796b05ff2974340 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 2 Feb 2022 18:46:52 +0100 Subject: [PATCH 2/3] PEP8 fix --- reframe/frontend/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index efb1119fb2..84a7ee2eaf 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -769,8 +769,8 @@ def restrict_logging(): if config_param == 'all': printer.info(str(rt.site_config)) else: - # Create a unique value to check against configuration parameters with - # value `None` and invalid ones + # Create a unique value to differentiate between configuration + # parameters with value `None` and invalid ones default = time.time() value = rt.get_option(config_param, default) if value == default: From 4ffeb08e1214ed00136541686cf981bb4d2a0c22 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 3 Feb 2022 08:47:20 +0100 Subject: [PATCH 3/3] Address PR comments and add unittest --- reframe/frontend/cli.py | 4 ++-- unittests/test_cli.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 84a7ee2eaf..3bc4cd26fa 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -771,9 +771,9 @@ def restrict_logging(): else: # Create a unique value to differentiate between configuration # parameters with value `None` and invalid ones - default = time.time() + default = {'token'} value = rt.get_option(config_param, default) - if value == default: + if value is default: printer.error( f'no such configuration parameter found: {config_param}' ) diff --git a/unittests/test_cli.py b/unittests/test_cli.py index acd60533e1..74bc9b80aa 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -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'],