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

Handle unknown statement while parsing profile. Fixes #6931 #7577

Merged
merged 5 commits into from
Aug 24, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion conans/client/profile_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def __init__(self, text):
include = include[:-1]
self.includes.append(include)
else:
name, value = line.split("=", 1)
try:
name, value = line.split("=", 1)
except ValueError as error:
raise ConanException("Error while parsing line %i: '%s'" % (counter, line))
name = name.strip()
if " " in name:
raise ConanException("The names of the variables cannot contain spaces")
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/command/install/install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def requirements(self):
client.run("install . -pr=myotherprofile")
self.assertIn("PKGOS=FreeBSD", client.out)
client.run("install . -pr=./myotherprofile", assert_error=True)
self.assertIn("Error parsing the profile", client.out)
self.assertIn("Error while parsing line 0", client.out)

def install_with_path_errors_test(self):
client = TestClient()
Expand Down
11 changes: 11 additions & 0 deletions conans/test/unittests/client/profile_loader/profile_loader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def test_parser(self):
os=thing""")


txt = """
includes(a/path/to\profile.txt)
"""
with self.assertRaises(ConanException):
try:
ProfileParser(txt)
except Exception as error:
self.assertIn("Error while parsing line 1", error.args[0])
raise


class ProfileTest(unittest.TestCase):

def profile_loads_test(self):
Expand Down