summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRĂ©mi Lacroix <remi.lacroix@idris.fr>2020-09-09 18:05:58 +0200
committerGitHub <noreply@github.com>2020-09-09 18:05:58 +0200
commitfa04ad5d928f097318ac1ace265a9511ab6d08f5 (patch)
tree65dc4cbcb439e22d3d747cf87b5e608a949ee94e /lib
parent3dedd2e321ffdcae4bfed4a9ea5df1d505faf70c (diff)
downloadspack-fa04ad5d928f097318ac1ace265a9511ab6d08f5.tar.gz
spack-fa04ad5d928f097318ac1ace265a9511ab6d08f5.tar.bz2
spack-fa04ad5d928f097318ac1ace265a9511ab6d08f5.tar.xz
spack-fa04ad5d928f097318ac1ace265a9511ab6d08f5.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/modules/common.py6
-rw-r--r--lib/spack/spack/test/data/modules/tcl/override_config.yaml13
-rw-r--r--lib/spack/spack/test/modules/tcl.py14
3 files changed, 28 insertions, 5 deletions
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index 42fc398e47..cbc064520c 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -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)
diff --git a/lib/spack/spack/test/data/modules/tcl/override_config.yaml b/lib/spack/spack/test/data/modules/tcl/override_config.yaml
new file mode 100644
index 0000000000..4d3aaea7ae
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/override_config.yaml
@@ -0,0 +1,13 @@
+enable:
+ - tcl
+tcl:
+ all:
+ suffixes:
+ '^mpich': mpich
+ mpileaks:
+ suffixes:
+ '+static': static
+ mpileaks+opt::
+ suffixes:
+ '~debug': over
+ '^mpich': ridden
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 68f9af13c6..ec0b47c484 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -298,6 +298,20 @@ class TestTcl(object):
[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
):