From 598c25b434aa2599f4ad45cff3749efd36c99c9e Mon Sep 17 00:00:00 2001 From: Andrew W Elble Date: Wed, 2 Dec 2020 03:53:53 -0500 Subject: [PATCH] concretizer: don't optimize emitting version_satisfies() (#20128) When all versions were allowed a version_satisfies rule was not emitted, and this caused conditional directives to fail. --- lib/spack/spack/solver/asp.py | 4 ---- lib/spack/spack/test/concretize.py | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 9c785464553..f0fa41fb6e0 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1395,10 +1395,6 @@ def define_version_constraints(self): if exact_match: allowed_versions = exact_match - # don't bother restricting anything if all versions are allowed - if len(allowed_versions) == len(self.possible_versions[pkg_name]): - continue - predicates = [fn.version(pkg_name, v) for v in allowed_versions] # version_satisfies(pkg, constraint) is true if and only if a diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index fa08eb8097a..e5cd8b162ad 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -501,6 +501,11 @@ def test_conflicts_in_spec(self, conflict_spec): with pytest.raises(spack.error.SpackError): s.concretize() + def test_conflict_in_all_directives_true(self): + s = Spec('when-directives-true') + with pytest.raises(spack.error.SpackError): + s.concretize() + @pytest.mark.parametrize('spec_str', [ 'conflict@10.0%clang+foo' ])