Skip to content

Commit 77444df

Browse files
alalazotgamblin
authored andcommitted
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.
1 parent 7af8c20 commit 77444df

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/spack/spack/spec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ def _satisfies_target(self, other_target, strict):
395395
if not sep and self_target == t_min:
396396
return True
397397

398+
if not sep and self_target != t_min:
399+
return False
400+
401+
# Check against a range
398402
min_ok = self_target.microarchitecture >= t_min if t_min else True
399403
max_ok = self_target.microarchitecture <= t_max if t_max else True
400404

lib/spack/spack/test/spec_semantics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,12 @@ def test_forwarding_of_architecture_attributes(self):
972972
('libelf target=haswell', 'target=:haswell', True),
973973
('libelf target=haswell', 'target=icelake,:nocona', False),
974974
('libelf target=haswell', 'target=haswell,:nocona', True),
975+
# Check that a single target is not treated as the start
976+
# or the end of an open range
977+
('libelf target=haswell', 'target=x86_64', False),
978+
('libelf target=x86_64', 'target=haswell', False),
975979
])
980+
@pytest.mark.regression('13111')
976981
def test_target_constraints(self, spec, constraint, expected_result):
977982
s = Spec(spec)
978983
assert s.satisfies(constraint) is expected_result

0 commit comments

Comments
 (0)