concretizer: dependency conditions cannot hold if package is external

fixes #20736

Before this one line fix we were erroneously deducing
that dependency conditions hold even if a package
was external.

This may result in answer sets that contain imposed
conditions on a node without the node being present
in the DAG, hence #20736.
This commit is contained in:
Massimiliano Culpo 2021-01-12 12:35:48 +01:00 committed by Todd Gamblin
parent a2eb587a95
commit ed8fe68cf2
4 changed files with 12 additions and 2 deletions

View File

@ -93,7 +93,8 @@ dependency_conditions_hold(ID, Parent, Dependency) :-
attr(Name, Arg1, Arg2) : required_dependency_condition(ID, Name, Arg1, Arg2);
attr(Name, Arg1, Arg2, Arg3) : required_dependency_condition(ID, Name, Arg1, Arg2, Arg3);
dependency_condition(ID, Parent, Dependency);
node(Parent).
node(Parent);
not external(Parent).
#defined dependency_condition/3.
#defined required_dependency_condition/3.

View File

@ -1044,7 +1044,7 @@ def test_dont_select_version_that_brings_more_variants_in(self):
s = Spec('dep-with-variants-if-develop-root').concretized()
assert s['dep-with-variants-if-develop'].satisfies('@1.0')
@pytest.mark.regression('20244')
@pytest.mark.regression('20244,20736')
@pytest.mark.parametrize('spec_str,is_external,expected', [
# These are all externals, and 0_8 is a version not in package.py
('externaltool@1.0', True, '@1.0'),
@ -1056,6 +1056,10 @@ def test_dont_select_version_that_brings_more_variants_in(self):
('external-buildable-with-variant +baz', True, '@1.1.special +baz'),
('external-buildable-with-variant ~baz', False, '@1.0 ~baz'),
('external-buildable-with-variant@1.0: ~baz', False, '@1.0 ~baz'),
# This uses an external version that meets the condition for
# having an additional dependency, but the dependency shouldn't
# appear in the answer set
('external-buildable-with-variant@0.9 +baz', True, '@0.9'),
])
def test_external_package_versions(self, spec_str, is_external, expected):
s = Spec(spec_str).concretized()

View File

@ -34,3 +34,5 @@ packages:
externals:
- spec: external-buildable-with-variant@1.1.special +baz
prefix: /usr
- spec: external-buildable-with-variant@0.9 +baz
prefix: /usr

View File

@ -11,5 +11,8 @@ class ExternalBuildableWithVariant(Package):
url = "http://somewhere.com/module-1.0.tar.gz"
version('1.0', '1234567890abcdef1234567890abcdef')
version('0.9', '1234567890abcdef1234567890abcdef')
variant('baz', default=False, description='nope')
depends_on('c@1.0', when='@0.9')