Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conan/internal/model/recipe_ref.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from conan.api.model import RecipeReference
from conan.api.output import ConanOutput


def ref_matches(ref, pattern, is_consumer):
if not ref or not str(ref):
assert is_consumer
ref = RecipeReference.loads("*/*") # FIXME: ugly
if pattern.startswith("["):
ConanOutput().warning(f"Pattern {pattern} contains a version range, which has no effect. "
f"Only '&' for consumer and '*' as wildcard are supported in this context.",
warn_tag="risk")
return ref.matches(pattern, is_consumer=is_consumer)
13 changes: 13 additions & 0 deletions test/integration/options/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,19 @@ def configure(self):
assert "dep3/1.0: SHARED: True!!" in c.out
assert "dep4/1.0: SHARED: True!!" in c.out

def test_pattern_version_range_warn(self):
c = TestClient(light=True)
c.save({"conanfile.py": GenConanfile("foo", "1.0")})
c.run("create -o=foo/[>1]:shared=True")
assert "WARN: risk: Pattern foo/[>1] contains a version range" in c.out

def test_pattern_version_range_wrong_split(self):
c = TestClient(light=True)
c.save({"conanfile.py": GenConanfile("foo", "1.0")})
c.run("create -o=foo/[>=1]:shared=True", assert_error=True)
# We split by the first =, so this version range we can't catch and warn before it breaks
assert "option 'foo/[>' doesn't exist" in c.out


class TestTransitiveOptionsShared:
"""
Expand Down
Loading