Add a unit-test for satisfies and __getitem__ semantic

This commit is contained in:
Massimiliano Culpo 2024-10-28 21:58:50 +01:00
parent 2fd89f7e59
commit 8f96ac3d03
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -1966,3 +1966,44 @@ def test_equality_discriminate_on_propagation(lhs, rhs):
def test_comparison_multivalued_variants():
assert Spec("x=a") < Spec("x=a,b") < Spec("x==a,b") < Spec("x==a,b,c")
def test_satisfies_and_subscript_with_compilers(default_mock_concretization):
"""Tests the semantic of "satisfies" and __getitem__ for the following spec:
[ ] multivalue-variant@2.3
[bl ] ^callpath@1.0
[bl ] ^dyninst@8.2
[bl ] ^libdwarf@20130729
[bl ] ^libelf@0.8.13
[b ] ^gcc@10.2.1
[ l ] ^gcc-runtime@10.2.1
[bl ] ^mpich@3.0.4
[bl ] ^pkg-a@2.0
[b ] ^gmake@4.4
[bl ] ^pkg-b@1.0
"""
s = default_mock_concretization("multivalue-variant")
# Check a direct build/link dependency
assert s.satisfies("^pkg-a")
assert s.dependencies(name="pkg-a")[0] == s["pkg-a"]
# Transitive build/link dependency
assert s.satisfies("^libelf")
assert s["libdwarf"].dependencies(name="libelf")[0] == s["libelf"]
# Direct build dependencies
assert s.satisfies("^[virtuals=c] gcc")
assert s.dependencies(name="gcc")[0] == s["gcc"]
assert s.dependencies(name="gcc")[0] == s["c"]
# Transitive build dependencies
assert s.satisfies("^gmake")
# "gmake" is not in the link/run subdag + direct build deps
with pytest.raises(KeyError):
_ = s["gmake"]
# We need to pass through "pkg-a" to get "gmake" with [] notation
assert s["pkg-a"].dependencies(name="gmake")[0] == s["pkg-a"]["gmake"]