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:
parent
3dedd2e321
commit
fa04ad5d92
@ -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)
|
||||
|
||||
|
13
lib/spack/spack/test/data/modules/tcl/override_config.yaml
Normal file
13
lib/spack/spack/test/data/modules/tcl/override_config.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
enable:
|
||||
- tcl
|
||||
tcl:
|
||||
all:
|
||||
suffixes:
|
||||
'^mpich': mpich
|
||||
mpileaks:
|
||||
suffixes:
|
||||
'+static': static
|
||||
mpileaks+opt::
|
||||
suffixes:
|
||||
'~debug': over
|
||||
'^mpich': ridden
|
@ -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
|
||||
):
|
||||
|
Loading…
Reference in New Issue
Block a user