Spec: fix multiple generator iteration in satisfies_dependencies (#18527) (#18559)

This commit is contained in:
Omri Mor 2020-10-17 02:40:31 -07:00 committed by GitHub
parent 1a6c5ff541
commit bff0291dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -3009,8 +3009,9 @@ def satisfies_dependencies(self, other, strict=False):
if not self._dependencies: if not self._dependencies:
return False return False
selfdeps = self.traverse(root=False) # use list to prevent double-iteration
otherdeps = other.traverse(root=False) selfdeps = list(self.traverse(root=False))
otherdeps = list(other.traverse(root=False))
if not all(any(d.satisfies(dep, strict=True) for d in selfdeps) if not all(any(d.satisfies(dep, strict=True) for d in selfdeps)
for dep in otherdeps): for dep in otherdeps):
return False return False

View File

@ -1014,6 +1014,13 @@ def test_error_message_unknown_variant(self):
with pytest.raises(UnknownVariantError, match=r'package has no such'): with pytest.raises(UnknownVariantError, match=r'package has no such'):
s.concretize() s.concretize()
@pytest.mark.regression('18527')
def test_satisfies_dependencies_ordered(self):
d = Spec('zmpi ^fake')
s = Spec('mpileaks')
s._add_dependency(d, ())
assert s.satisfies('mpileaks ^zmpi ^fake', strict=True)
@pytest.mark.regression('3887') @pytest.mark.regression('3887')
@pytest.mark.parametrize('spec_str', [ @pytest.mark.parametrize('spec_str', [