summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-08-26 18:28:47 +0200
committerGitHub <noreply@github.com>2021-08-26 09:28:47 -0700
commit7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7 (patch)
treed5ff27e4465846f503aed75c4acbe22e94abd7e3 /lib
parente602c40d09e9b398e227a66838750f24c9dc1a5f (diff)
downloadspack-7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7.tar.gz
spack-7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7.tar.bz2
spack-7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7.tar.xz
spack-7dd3592eabe2b1ab2739a3e54c5228465c4c6ae7.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/concretize_preferences.py12
-rw-r--r--lib/spack/spack/test/data/config/packages.yaml2
2 files changed, 14 insertions, 0 deletions
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