From 77444dff106524b0b33f664e5fe1f4512ec511d7 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 9 Oct 2019 23:32:27 +0200 Subject: ArchSpec: fix constraint satisfaction for targets fixes #13111 Due to a missing case we were treating a single target that was not equal to the one we were comparing to as a range open on the right. --- lib/spack/spack/spec.py | 4 ++++ lib/spack/spack/test/spec_semantics.py | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 99246ebb02..0cde672de2 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -395,6 +395,10 @@ class ArchSpec(object): if not sep and self_target == t_min: return True + if not sep and self_target != t_min: + return False + + # Check against a range min_ok = self_target.microarchitecture >= t_min if t_min else True max_ok = self_target.microarchitecture <= t_max if t_max else True diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index 0c52bd1c10..a183742e65 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -972,7 +972,12 @@ class TestSpecSematics(object): ('libelf target=haswell', 'target=:haswell', True), ('libelf target=haswell', 'target=icelake,:nocona', False), ('libelf target=haswell', 'target=haswell,:nocona', True), + # Check that a single target is not treated as the start + # or the end of an open range + ('libelf target=haswell', 'target=x86_64', False), + ('libelf target=x86_64', 'target=haswell', False), ]) + @pytest.mark.regression('13111') def test_target_constraints(self, spec, constraint, expected_result): s = Spec(spec) assert s.satisfies(constraint) is expected_result -- cgit v1.2.3-70-g09d2