summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2021-02-10 01:26:54 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2021-05-22 11:51:20 -0700
commit9717e0244f70892ec4cf8573bf0b88ec95840894 (patch)
tree8260c1b3055366fab9efc63b63ce66aa0823b2ff /lib
parenta823cffc40dda0738a9b8848c424efaa8a8ece2e (diff)
downloadspack-9717e0244f70892ec4cf8573bf0b88ec95840894.tar.gz
spack-9717e0244f70892ec4cf8573bf0b88ec95840894.tar.bz2
spack-9717e0244f70892ec4cf8573bf0b88ec95840894.tar.xz
spack-9717e0244f70892ec4cf8573bf0b88ec95840894.zip
bugfix: do not generate dep conditions when no dependency
We only consider test dependencies some of the time. Some packages are *only* test dependencies. Spack's algorithm was previously generating dependency conditions that could hold, *even* if there was no potential dependency type. - [x] change asp.py so that this can't happen -- we now only generate dependency types for possible dependencies.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 61d18fc65e..11b8b99518 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -683,21 +683,26 @@ class SpackSolverSetup(object):
"""Translate 'depends_on' directives into ASP logic."""
for _, conditions in sorted(pkg.dependencies.items()):
for cond, dep in sorted(conditions.items()):
+ deptypes = dep.type.copy()
+ # Skip test dependencies if they're not requested
+ if not tests:
+ deptypes.discard("test")
+
+ # ... or if they are requested only for certain packages
+ if not isinstance(tests, bool) and pkg.name not in tests:
+ deptypes.discard("test")
+
+ # if there are no dependency types to be considered
+ # anymore, don't generate the dependency
+ if not deptypes:
+ continue
+
condition_id = self.condition(cond, dep.spec, pkg.name)
self.gen.fact(fn.dependency_condition(
condition_id, pkg.name, dep.spec.name
))
- for t in sorted(dep.type):
- # Skip test dependencies if they're not requested at all
- if t == 'test' and not tests:
- continue
-
- # ... or if they are requested only for certain packages
- if t == 'test' and (not isinstance(tests, bool)
- and pkg.name not in tests):
- continue
-
+ for t in sorted(deptypes):
# there is a declared dependency of type t
self.gen.fact(fn.dependency_type(condition_id, t))