Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn of unknown version range options #14493

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions conans/model/version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def __init__(self, expression):
if "include_prerelease" in t:
prereleases = True
break
else:
t = t.strip()
if len(t) > 0 and t[0].isalpha():
from conan.api.output import ConanOutput
ConanOutput().warning(f'Unrecognized version range option "{t}" in "{expression}"')
else:
raise ConanException(f'"{t}" in version range "{expression}" is not a valid option')
version_expr = tokens[0]
self.condition_sets = []
for alternative in version_expr.split("||"):
Expand Down
12 changes: 12 additions & 0 deletions conans/test/integration/graph/core/test_version_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,15 @@ def test_different_user_channel_resolved_correctly():
client2.run("install --requires=lib/[>=1.0]@conan/testing")
assert f"lib/1.0@conan/testing: Retrieving package {NO_SETTINGS_PACKAGE_ID} " \
f"from remote 'server2' " in client2.out


def test_unknown_options():
c = TestClient()
c.save({"conanfile.py": GenConanfile("lib", "2.0")})
c.run("create .")

c.run("graph info --requires=lib/[>1.2,<1.4]", assert_error=True)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
assert '"<1.4" in version range ">1.2,<1.4" is not a valid option' in c.out

c.run("graph info --requires=lib/[>1.2,unknown_conf]")
assert 'WARN: Unrecognized version range option "unknown_conf" in ">1.2,unknown_conf"' in c.out
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_reuse_version_ranges(self):
reuse = textwrap.dedent("""
from conan import ConanFile
class PkgTest(ConanFile):
python_requires = "base/[>1.0,<1.2]@user/testing"
python_requires = "base/[>1.0 <1.2]@user/testing"
python_requires_extend = "base.MyConanfileBase"
""")

Expand Down