Skip to content

Commit 233ac11

Browse files
committed
Merge branch 'fix/version_constraints_with_unequal' into 'main'
fix: union of constraints of unequal clauses Closes PACMAN-943 See merge request espressif/idf-component-manager!424
2 parents b4fc561 + 61055f0 commit 233ac11

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

idf_component_manager/version_solver/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def parse_single_constraint(
4848
elif _range.operator == _range.OP_GTE:
4949
return Range(min=version, include_min=True, string=str(_range))
5050
elif _range.operator == _range.OP_NEQ:
51-
return Union(Range(min=version, string=str(_range)), Range(max=version, string=str(_range)))
51+
return Union(Range(max=version, string=str(_range)), Range(min=version, string=str(_range)))
5252
else:
5353
return Range(version, version, True, True, str(_range))
5454

@@ -168,7 +168,7 @@ def convert_dependency(self, dependency: Dependency) -> Constraint:
168168
)
169169
for r in dependency.constraint.ranges
170170
]
171-
constraint = Union.of(ranges)
171+
constraint = Union.of(*ranges)
172172
else:
173173
raise ValueError('should be "Union" or "Range"')
174174

tests/version_solver/test_range.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from idf_component_manager.version_solver.helper import parse_constraint
5+
6+
7+
def test_parse_union_of_multiple_unequal():
8+
assert parse_constraint('!=5.0.2,!=5.1.3,!=5.2.1')
9+
10+
11+
def test_union_of_multiple_unequal():
12+
a = parse_constraint('!=5.0.2')
13+
b = parse_constraint('!=5.1.3')
14+
c = parse_constraint('!=5.2.1')
15+
16+
d = a.intersect(b).intersect(c)
17+
18+
assert str(d) == '<5.0.2 || >5.0.2,<5.1.3 || >5.1.3,<5.2.1 || >5.2.1'
19+
assert d.ranges[0] == parse_constraint('<5.0.2')
20+
assert d.ranges[1] == parse_constraint('>5.0.2,<5.1.3')
21+
assert d.ranges[2] == parse_constraint('>5.1.3,<5.2.1')
22+
assert d.ranges[3] == parse_constraint('>5.2.1')

0 commit comments

Comments
 (0)