summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2018-10-25 23:56:03 +0200
committerGitHub <noreply@github.com>2018-10-25 23:56:03 +0200
commitda537d2211f60b8e02f4acd6677b98f82a0cf2ff (patch)
tree8db9b68677d46774591d5099dfd10581dc557887 /lib
parent534b71bdf10ce5331a08ed70a00e86a21b56df19 (diff)
downloadspack-da537d2211f60b8e02f4acd6677b98f82a0cf2ff.tar.gz
spack-da537d2211f60b8e02f4acd6677b98f82a0cf2ff.tar.bz2
spack-da537d2211f60b8e02f4acd6677b98f82a0cf2ff.tar.xz
spack-da537d2211f60b8e02f4acd6677b98f82a0cf2ff.zip
Fix autoload of direct dependencies for python (#9630)
fixes #9624 merge_config_rules was using `strict=False` to check if a spec satisfies a constraint, which loosely translates to "this spec has no conflict with the constraint, so I can potentially add it to the spec". We want instead `strict=True` which means "the spec satisfies the constraint right now".
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/modules/common.py2
-rw-r--r--lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml8
-rw-r--r--lib/spack/spack/test/modules/tcl.py17
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index 1ed826a844..6e0d062156 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -173,7 +173,7 @@ def merge_config_rules(configuration, spec):
if constraint.endswith(':'):
constraint = constraint.strip(':')
override = True
- if spec.satisfies(constraint):
+ if spec.satisfies(constraint, strict=True):
if override:
spec_configuration = {}
update_dictionary_extending_lists(spec_configuration, action)
diff --git a/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml b/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml
new file mode 100644
index 0000000000..52796cad5b
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml
@@ -0,0 +1,8 @@
+enable:
+ - tcl
+tcl:
+ ^mpich2:
+ autoload: 'direct'
+
+ ^python:
+ autoload: 'direct'
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 9846b20482..b7b6a023ce 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -276,3 +276,20 @@ class TestTcl(object):
for item in callpath_specs:
writer = writer_cls(item)
assert writer.conf.blacklisted
+
+ @pytest.mark.regression('9624')
+ @pytest.mark.db
+ def test_autoload_with_constraints(
+ self, modulefile_content, module_configuration, database
+ ):
+ """Tests the automatic loading of direct dependencies."""
+
+ module_configuration('autoload_with_constraints')
+
+ # Test the mpileaks that should have the autoloaded dependencies
+ content = modulefile_content('mpileaks ^mpich2')
+ assert len([x for x in content if 'is-loaded' in x]) == 2
+
+ # Test the mpileaks that should NOT have the autoloaded dependencies
+ content = modulefile_content('mpileaks ^mpich')
+ assert len([x for x in content if 'is-loaded' in x]) == 0