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

Print specific error message for an invalid package #608

Merged
merged 6 commits into from
May 21, 2018
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
4 changes: 4 additions & 0 deletions src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
from .catkin_packages import find_catkin_packages_in
from .catkin_packages import set_workspace_packages
from .catkin_packages import get_workspace_packages
from catkin_pkg.package import InvalidPackage


class UsageError(Exception):
Expand Down Expand Up @@ -175,6 +176,9 @@ def rosdep_main(args=None):
except UnsupportedOs as e:
print('Unsupported OS: %s\nSupported OSes are [%s]' % (e.args[0], ', '.join(e.args[1])), file=sys.stderr)
sys.exit(1)
except InvalidPackage as e:
print(str(e))
sys.exit(1)
except Exception as e:
print("""
ERROR: Rosdep experienced an error: %s
Expand Down
8 changes: 8 additions & 0 deletions test/main/invalid_package_version/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<package>
<name>foo</name>
<version>:{version}</version>
<description>Package Foo</description>
<license>BSD</license>
<maintainer email="[email protected]">Foo Bar</maintainer>
</package>
12 changes: 12 additions & 0 deletions test/test_rosdep_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,15 @@ def test_proxy_detection(self, proxy, bah, build, install):
with patch.dict('os.environ', {'https_proxy': 'somethings'}, clear=True):
setup_proxy_opener()
proxy.assert_called_with({'https': 'somethings'})

def test_invalid_package_message(self):
with fakeout() as b:
test_package_dir = os.path.abspath(os.path.join(get_test_dir(), 'main', 'invalid_package_version'))
with patch('rosdep2.main.sys.exit') as exit_mock:
rosdep_main(['install', '--from-path', test_package_dir])
exit_mock.assert_called_with(1)
stdout, stderr = b
output = stdout.getvalue().splitlines()
assert len(output) == 2
assert test_package_dir in output[0]
assert 'Package version ":{version}" does not follow version conventions' in output[1]