tcl module files: fix configuration overriding (#18514)

This is a special case of overriding since each section is being matched with the current spec.

The trailing ':' for sections with override is now removed when parsing the configuration so the special handling for the modules configuration stopped working but it went unnoticed.
This commit is contained in:
Rémi Lacroix 2020-09-09 18:05:58 +02:00 committed by GitHub
parent 3dedd2e321
commit fa04ad5d92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 5 deletions

View File

@ -174,12 +174,8 @@ def merge_config_rules(configuration, spec):
# evaluated in order of appearance in the module file
spec_configuration = module_specific_configuration.pop('all', {})
for constraint, action in module_specific_configuration.items():
override = False
if constraint.endswith(':'):
constraint = constraint.strip(':')
override = True
if spec.satisfies(constraint, strict=True):
if override:
if hasattr(constraint, 'override') and constraint.override:
spec_configuration = {}
update_dictionary_extending_lists(spec_configuration, action)

View File

@ -0,0 +1,13 @@
enable:
- tcl
tcl:
all:
suffixes:
'^mpich': mpich
mpileaks:
suffixes:
'+static': static
mpileaks+opt::
suffixes:
'~debug': over
'^mpich': ridden

View File

@ -298,6 +298,20 @@ def test_setup_environment(self, modulefile_content, module_configuration):
[x for x in content if 'setenv FOOBAR "callpath"' in x]
) == 1
def test_override_config(self, module_configuration, factory):
"""Tests overriding some sections of the configuration file."""
module_configuration('override_config')
writer, spec = factory('mpileaks~opt arch=x86-linux')
assert 'mpich-static' in writer.layout.use_name
assert 'over' not in writer.layout.use_name
assert 'ridden' not in writer.layout.use_name
writer, spec = factory('mpileaks+opt arch=x86-linux')
assert 'over-ridden' in writer.layout.use_name
assert 'mpich' not in writer.layout.use_name
assert 'static' not in writer.layout.use_name
def test_override_template_in_package(
self, modulefile_content, module_configuration
):