From 94aed9918ebe67a9166bbe587dfd8aa3e001ff86 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 25 Nov 2022 21:24:27 +0100 Subject: [PATCH] Do not require 'handlers$' in the logging config This allows config files to define logging partially for specific systems and inherit its value from the builtin config. --- reframe/core/config.py | 7 ++++++- reframe/schemas/config.json | 1 - unittests/test_config.py | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/reframe/core/config.py b/reframe/core/config.py index cde58157a3..9dda285137 100644 --- a/reframe/core/config.py +++ b/reframe/core/config.py @@ -571,7 +571,12 @@ def select_subconfig(self, system_fullname=None, f"for system '{system_fullname}'" ) - # Verify that all environments defined by the system are defined for + # Check that handlers$ are defined for the current system + if 'handlers$' not in local_config['logging'][0]: + raise ConfigError(f"'logging/handlers$' are not defined " + f"for system {system_fullname!r}") + + # Check that all environments defined by the system are defined for # the current system if not ignore_resolve_errors: sys_environs = { diff --git a/reframe/schemas/config.json b/reframe/schemas/config.json index 08ef062f66..3897fc7bdf 100644 --- a/reframe/schemas/config.json +++ b/reframe/schemas/config.json @@ -451,7 +451,6 @@ }, "target_systems": {"$ref": "#/defs/system_ref"} }, - "required": ["handlers$"], "additionalProperties": false } }, diff --git a/unittests/test_config.py b/unittests/test_config.py index c4617b2ce0..80fa7dd2af 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -207,6 +207,14 @@ def test_select_subconfig_ignore_no_section_errors(): site_config.select_subconfig(ignore_resolve_errors=True) +def test_select_subconfig_empty_logging(): + site_config = config.load_config('reframe/core/settings.py') + site_config['logging'][0] = {} + with pytest.raises(ConfigError, + match=rf"'logging/handlers\$' are not defined"): + site_config.select_subconfig() + + def test_select_subconfig(site_config): site_config.select_subconfig('testsys') assert len(site_config['systems']) == 1