From fc576a40d66ad6f83fd512ce053cc83e011a1e30 Mon Sep 17 00:00:00 2001
From: alalazo <massimiliano.culpo@googlemail.com>
Date: Tue, 6 Sep 2016 15:07:11 +0200
Subject: [PATCH] modules : ('build',) type dependencies are not accounted when
 autoloading

fixes #1681
---
 lib/spack/spack/modules.py      |  3 ++-
 lib/spack/spack/test/modules.py | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 70c3c35d8c..3db08a6e90 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -120,7 +120,7 @@ def dependencies(spec, request='all'):
         return []
 
     if request == 'direct':
-        return spec.dependencies()
+        return spec.dependencies(deptype=('link', 'run'))
 
     # FIXME : during module file creation nodes seem to be visited multiple
     # FIXME : times even if cover='nodes' is given. This work around permits
@@ -133,6 +133,7 @@ def dependencies(spec, request='all'):
              spec.traverse(order='post',
                            depth=True,
                            cover='nodes',
+                           deptype=('link', 'run'),
                            root=False),
              reverse=True)]
     return [xx for ii, xx in l if not (xx in seen or seen_add(xx))]
diff --git a/lib/spack/spack/test/modules.py b/lib/spack/spack/test/modules.py
index 5e280d8e43..55b771fc79 100644
--- a/lib/spack/spack/test/modules.py
+++ b/lib/spack/spack/test/modules.py
@@ -229,6 +229,28 @@ def test_autoload(self):
         self.assertEqual(len([x for x in content if 'is-loaded' in x]), 5)
         self.assertEqual(len([x for x in content if 'module load ' in x]), 5)
 
+        # dtbuild1 has
+        # - 1 ('run',) dependency
+        # - 1 ('build','link') dependency
+        # - 1 ('build',) dependency
+        # Just make sure the 'build' dependency is not there
+        spack.modules.CONFIGURATION = configuration_autoload_direct
+        spec = spack.spec.Spec('dtbuild1')
+        content = self.get_modulefile_content(spec)
+        self.assertEqual(len([x for x in content if 'is-loaded' in x]), 2)
+        self.assertEqual(len([x for x in content if 'module load ' in x]), 2)
+
+        # dtbuild1 has
+        # - 1 ('run',) dependency
+        # - 1 ('build','link') dependency
+        # - 1 ('build',) dependency
+        # Just make sure the 'build' dependency is not there
+        spack.modules.CONFIGURATION = configuration_autoload_all
+        spec = spack.spec.Spec('dtbuild1')
+        content = self.get_modulefile_content(spec)
+        self.assertEqual(len([x for x in content if 'is-loaded' in x]), 2)
+        self.assertEqual(len([x for x in content if 'module load ' in x]), 2)
+
     def test_prerequisites(self):
         spack.modules.CONFIGURATION = configuration_prerequisites_direct
         spec = spack.spec.Spec('mpileaks arch=x86-linux')
-- 
GitLab