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 1 commit
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
6 changes: 5 additions & 1 deletion conans/model/version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ def __init__(self, expression):
prereleases = True
break
else:
t = t.strip()
from conan.api.output import ConanOutput
ConanOutput().warning(f'Unrecognized version range option "{t}" in "{expression}"')
if len(t) == 0 or t[0].isalpha():
ConanOutput().warning(f'Unrecognized version range option "{t}" in "{expression}"')
else:
ConanOutput().error(f'"{t}" in version range "{expression}" is not a valid option')
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
version_expr = tokens[0]
self.condition_sets = []
for alternative in version_expr.split("||"):
Expand Down
9 changes: 6 additions & 3 deletions conans/test/integration/graph/core/test_version_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ def test_different_user_channel_resolved_correctly():

def test_unknown_options():
c = TestClient()
c.save({"conanfile.py": GenConanfile("pkg", "1.0").with_requirement("lib/[>1.2, <1.4]")})
c.run("install .", assert_error=True)
assert 'Unrecognized version range option " <1.4" in ">1.2, <1.4"' in c.out

c.run("graph info --requires=lib/[>1.2,<1.4]", assert_error=True)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
assert 'ERROR: "<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_error=True)
assert 'WARN: Unrecognized version range option "unknown_conf" in ">1.2,unknown_conf"' in c.out