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.
This commit is contained in:
Massimiliano Culpo
2021-08-26 18:28:47 +02:00
committed by GitHub
parent e602c40d09
commit 7dd3592eab
5 changed files with 60 additions and 0 deletions

View File

@@ -384,3 +384,15 @@ def test_variant_not_flipped_to_pull_externals(self):
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

View File

@@ -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']