From fa04ad5d928f097318ac1ace265a9511ab6d08f5 Mon Sep 17 00:00:00 2001 From: RĂ©mi Lacroix Date: Wed, 9 Sep 2020 18:05:58 +0200 Subject: 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. --- lib/spack/spack/modules/common.py | 6 +----- lib/spack/spack/test/data/modules/tcl/override_config.yaml | 13 +++++++++++++ lib/spack/spack/test/modules/tcl.py | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 lib/spack/spack/test/data/modules/tcl/override_config.yaml (limited to 'lib') 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 ): -- cgit v1.2.3-70-g09d2