summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2024-11-07 20:29:37 +0100
committerGitHub <noreply@github.com>2024-11-07 19:29:37 +0000
commit0d817878ea25ecd2e0c7a5754f2ac877a1da7c59 (patch)
tree5d8cf672fa7ad5240d4afdb9035e7c4d4bf5bf2e
parentbf11fb037b799d8643d096dfb0991c33b801a716 (diff)
downloadspack-0d817878ea25ecd2e0c7a5754f2ac877a1da7c59.tar.gz
spack-0d817878ea25ecd2e0c7a5754f2ac877a1da7c59.tar.bz2
spack-0d817878ea25ecd2e0c7a5754f2ac877a1da7c59.tar.xz
spack-0d817878ea25ecd2e0c7a5754f2ac877a1da7c59.zip
spec.py: fix comparison with multivalued variants (#47485)
-rw-r--r--lib/spack/spack/test/spec_semantics.py4
-rw-r--r--lib/spack/spack/variant.py2
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py
index 6342325364..38424e951c 100644
--- a/lib/spack/spack/test/spec_semantics.py
+++ b/lib/spack/spack/test/spec_semantics.py
@@ -1975,3 +1975,7 @@ def test_equality_discriminate_on_propagation(lhs, rhs):
s, t = Spec(lhs), Spec(rhs)
assert s != t
assert len({s, t}) == 2
+
+
+def test_comparison_multivalued_variants():
+ assert Spec("x=a") < Spec("x=a,b") < Spec("x==a,b") < Spec("x==a,b,c")
diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py
index bce2015c12..e5a5ddfa3c 100644
--- a/lib/spack/spack/variant.py
+++ b/lib/spack/spack/variant.py
@@ -378,8 +378,8 @@ class AbstractVariant:
def _cmp_iter(self) -> Iterable:
yield self.name
- yield from (str(v) for v in self.value_as_tuple)
yield self.propagate
+ yield from (str(v) for v in self.value_as_tuple)
def copy(self) -> "AbstractVariant":
"""Returns an instance of a variant equivalent to self