Skip to content

Commit a48d21c

Browse files
committed
More checks
1 parent 6b14ec3 commit a48d21c

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

conan/internal/model/options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ def __init__(self, options=None, options_values=None):
242242
"deprecated, use a pattern like `{}/*:{}` " \
243243
"instead".format(k, package, option)
244244
raise ConanException(msg)
245+
if "[" in package:
246+
msg = (f"Options pattern {package} contains a version range, which has no effect. "
247+
f"Only '&' for consumer and '*' as wildcard are supported in this context.")
248+
from conan.api.output import ConanOutput
249+
ConanOutput().warning(msg, warn_tag="risk")
245250
self._deps_package_options.setdefault(package, _PackageOptions())[option] = v
246251
else:
247252
self._package_options[k] = v

test/integration/options/options_test.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,25 @@ def configure(self):
507507

508508
def test_pattern_version_range_warn(self):
509509
c = TestClient(light=True)
510-
c.save({"conanfile.py": GenConanfile("foo", "1.0")})
511-
c.run("create -o=foo/[>1]:shared=True")
512-
assert "WARN: risk: Pattern foo/[>1] contains a version range" in c.out
510+
profile = textwrap.dedent("""
511+
include(default)
512+
513+
[tool_requires]
514+
fmt/[*]:cmake/3.31.0
515+
516+
[options]
517+
fmt/[*]:shared=True
518+
519+
[settings]
520+
fmt/[*]:compiler.cppstd=17
521+
""")
522+
c.save({
523+
"profile": profile,
524+
"conanfile.py": GenConanfile("fmt", "1.0")})
525+
c.run("create -pr=profile")
526+
assert "WARN: risk: Settings pattern fmt/[*] contains a version range" in c.out
527+
assert "WARN: risk: Options pattern fmt/[*] contains a version range" in c.out
528+
assert "WARN: risk: Tool requires pattern fmt/[*] contains a version range" in c.out
513529

514530
def test_pattern_version_range_wrong_split(self):
515531
c = TestClient(light=True)

0 commit comments

Comments
 (0)