From eded8f48dc629a5f3a72acf9c134731f8b89606c Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 14 Oct 2021 23:06:41 +0200 Subject: ASP-based solver: add a rule for version uniqueness in virtual packages (#26740) fixes #26718 A virtual package may or may not have a version, but it never has more than one. Previously we were missing a rule for that. --- lib/spack/spack/solver/concretize.lp | 3 +++ lib/spack/spack/test/concretize.py | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index e444faffec..b85d2f798a 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -28,6 +28,9 @@ version_declared(Package, Version) :- version_declared(Package, Version, _). 1 { version(Package, Version) : version_declared(Package, Version) } 1 :- node(Package). +% A virtual package may have or not a version, but never has more than one +:- virtual_node(Package), 2 { version(Package, _) }. + % If we select a deprecated version, mark the package as deprecated deprecated(Package, Version) :- version(Package, Version), deprecated_version(Package, Version). diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index cb09f41c66..d30191f4f2 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -1267,3 +1267,10 @@ class TestConcretize(object): s = spack.spec.Spec('root-adds-virtual').concretized() assert s['leaf-adds-virtual'].satisfies('@2.0') assert 'blas' in s + + @pytest.mark.regression('26718') + def test_versions_in_virtual_dependencies(self): + # Ensure that a package that needs a given version of a virtual + # package doesn't end up using a later implementation + s = spack.spec.Spec('hpcviewer@2019.02').concretized() + assert s['java'].satisfies('virtual-with-versions@1.8.0') -- cgit v1.2.3-70-g09d2