From 7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 26 Aug 2021 18:28:47 +0200 Subject: Regression test for version selection with preferences (#25602) This commit adds a regression test for version selection with preferences in `packages.yaml`. Before PR 25585 we used negative weights in a minimization to select the optimal version. This may lead to situations where a dependency may make the version score of dependents "better" if it is preferred in packages.yaml. --- lib/spack/spack/test/concretize_preferences.py | 12 ++++++++++++ lib/spack/spack/test/data/config/packages.yaml | 2 ++ 2 files changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py index b5b631d6af..598e9d08fb 100644 --- a/lib/spack/spack/test/concretize_preferences.py +++ b/lib/spack/spack/test/concretize_preferences.py @@ -384,3 +384,15 @@ mpi: assert '~external' in s['vdefault-or-external'] assert 'externaltool' not in s + + @pytest.mark.regression('25585') + def test_dependencies_cant_make_version_parent_score_better(self): + """Test that a package can't select a worse version for a + dependent because doing so it can pull-in a dependency + that makes the overall version score even or better and maybe + has a better score in some lower priority criteria. + """ + s = Spec('version-test-root').concretized() + + assert s.satisfies('^version-test-pkg@2.4.6') + assert 'version-test-dependency-preferred' not in s diff --git a/lib/spack/spack/test/data/config/packages.yaml b/lib/spack/spack/test/data/config/packages.yaml index b2c3a33b42..84f470d208 100644 --- a/lib/spack/spack/test/data/config/packages.yaml +++ b/lib/spack/spack/test/data/config/packages.yaml @@ -47,3 +47,5 @@ packages: externals: - spec: external-non-default-variant@3.8.7~foo~bar prefix: /usr + version-test-dependency-preferred: + version: ['5.2.5'] \ No newline at end of file -- cgit v1.2.3-70-g09d2