{"action":"created","comment":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/47866932","id":47866932,"diff_hunk":"@@ -183,3 +331,136 @@ class Options:\n \n         self.assertTrue(os.path.exists(\n             os.path.join(plugin.builddir, 'src', 'src_subdir', 'file')))\n+\n+\n+class RosdepTestCase(tests.TestCase):\n+\n+    def setUp(self):\n+        super().setUp()\n+\n+        self.rosdep = catkin._Rosdep('ros_distro', 'package_path',\n+                                     'rosdep_path', 'sources')\n+\n+        patcher = mock.patch('snapcraft.repo.Ubuntu')\n+        self.ubuntu_mock = patcher.start()\n+        self.addCleanup(patcher.stop)\n+\n+        patcher = mock.patch('subprocess.check_output')\n+        self.run_mock = patcher.start()\n+        self.addCleanup(patcher.stop)\n+\n+    def test_setup(self):\n+        # Return something other than a Mock to ease later assertions\n+        self.run_mock.return_value = b''\n+\n+        self.rosdep.setup()\n+\n+        # Verify that only rosdep was installed (no other .debs)\n+        self.assertEqual(self.ubuntu_mock.call_count, 1)\n+        self.assertEqual(self.ubuntu_mock.return_value.get.call_count, 1)\n+        self.assertEqual(self.ubuntu_mock.return_value.unpack.call_count, 1)\n+        self.ubuntu_mock.assert_has_calls([\n+            mock.call(self.rosdep._rosdep_path, sources='sources'),\n+            mock.call().get(['python-rosdep']),\n+            mock.call().unpack(self.rosdep._rosdep_install_path)])\n+\n+        # Verify that rosdep was initialized and updated\n+        self.assertEqual(self.run_mock.call_count, 2)\n+        self.run_mock.assert_has_calls([\n+            mock.call(['rosdep', 'init'], env=mock.ANY),\n+            mock.call(['rosdep', 'update'], env=mock.ANY)\n+        ])\n+\n+    def test_setup_initialization_failure(self):\n+        def run(args, **kwargs):\n+            if args == ['rosdep', 'init']:\n+                raise subprocess.CalledProcessError(1, 'foo', 'bar')\n+\n+            return mock.DEFAULT\n+\n+        self.run_mock.side_effect = run\n+\n+        with self.assertRaises(RuntimeError) as raised:\n+            self.rosdep.setup()\n+\n+        self.assertEqual(raised.exception.args[0],\n+                         'Error initializing rosdep database: bar')\n+\n+    def test_setup_update_failure(self):\n+        def run(args, **kwargs):\n+            if args == ['rosdep', 'update']:\n+                raise subprocess.CalledProcessError(1, 'foo', 'bar')\n+\n+            return mock.DEFAULT\n+\n+        self.run_mock.side_effect = run\n+\n+        with self.assertRaises(RuntimeError) as raised:\n+            self.rosdep.setup()\n+\n+        self.assertEqual(raised.exception.args[0],\n+                         'Error updating rosdep database: bar')\n+\n+    def test_get_dependencies(self):\n+        self.run_mock.return_value = b'foo\\nbar\\nbaz'\n+\n+        self.assertEqual(self.rosdep.get_dependencies('foo'),\n+                         ['foo', 'bar', 'baz'])\n+\n+        self.run_mock.assert_called_with(['rosdep', 'keys', 'foo'],\n+                                         env=mock.ANY)\n+\n+    def test_get_dependencies_no_dependencies(self):\n+        self.run_mock.return_value = b''\n+\n+        self.assertEqual(self.rosdep.get_dependencies('foo'), [])\n+\n+    def test_get_dependencies_invalid_package(self):\n+        self.run_mock.side_effect = subprocess.CalledProcessError(1, 'foo')\n+\n+        with self.assertRaises(FileNotFoundError) as raised:\n+            self.rosdep.get_dependencies('bar')\n+\n+        self.assertEqual(raised.exception.args[0],\n+                         'Unable to find Catkin package \"bar\"')\n+\n+    def test_resolve_dependency(self):\n+        self.run_mock.return_value = b'#apt\\nmylib-dev'\n+\n+        self.assertEqual(self.rosdep.resolve_dependency('foo'), 'mylib-dev')\n+\n+        self.run_mock.assert_called_with(['rosdep', 'resolve', 'foo',\n+                                          '--rosdistro', 'ros_distro'],\n+                                         env=mock.ANY)\n+\n+    def test_resolve_invalid_dependency(self):\n+        self.run_mock.side_effect = subprocess.CalledProcessError(1, 'foo')\n+\n+        self.assertEqual(self.rosdep.resolve_dependency('bar'), None)\n+\n+    def test_resolve_dependency_weird_output(self):\n+        self.run_mock.return_value = b'mylib-dev'\n+\n+        with self.assertRaises(RuntimeError) as raised:\n+            self.rosdep.resolve_dependency('')\n+\n+        self.assertEqual(raised.exception.args[0],\n+                         'Unexpected rosdep resolve output:\\nmylib-dev')\n+\n+    def test_run(self):\n+        rosdep = self.rosdep\n+        rosdep._run(['qux'])\n+\n+        class check_env():\n+            def __eq__(self, env):\n+                return (\n+                    env['PATH'] == os.path.join(rosdep._rosdep_install_path,\n+                                                'usr', 'bin') and\n+                    env['PYTHONPATH'] == os.path.join(\n+                        rosdep._rosdep_install_path, 'usr', 'lib', 'python2.7',\n+                        'dist-packages') and\n+                    env['ROSDEP_SOURCE_PATH'] == rosdep._rosdep_sources_path\n+                    and env['ROS_HOME'] == rosdep._rosdep_cache_path and","path":"snapcraft/tests/test_plugin_catkin.py","position":492,"original_position":492,"commit_id":"320f122a0a3b4d6613aea887c543e28331e25d0e","original_commit_id":"320f122a0a3b4d6613aea887c543e28331e25d0e","user":{"login":"elopio","id":617831,"avatar_url":"https://avatars.githubusercontent.com/u/617831?v=3","gravatar_id":"","url":"https://api.github.com/users/elopio","html_url":"https://github.com/elopio","followers_url":"https://api.github.com/users/elopio/followers","following_url":"https://api.github.com/users/elopio/following{/other_user}","gists_url":"https://api.github.com/users/elopio/gists{/gist_id}","starred_url":"https://api.github.com/users/elopio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elopio/subscriptions","organizations_url":"https://api.github.com/users/elopio/orgs","repos_url":"https://api.github.com/users/elopio/repos","events_url":"https://api.github.com/users/elopio/events{/privacy}","received_events_url":"https://api.github.com/users/elopio/received_events","type":"User","site_admin":false},"body":"the and operator should be at the end of the line. flake8 complaints in xenial, it seems to ignore it in the travis's version.","created_at":"2015-12-17T03:57:21Z","updated_at":"2015-12-17T03:57:21Z","html_url":"https://github.com/ubuntu-core/snapcraft/pull/163#discussion_r47866932","pull_request_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163","_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/47866932"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/163#discussion_r47866932"},"pull_request":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163"}}},"pull_request":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163","id":53434112,"html_url":"https://github.com/ubuntu-core/snapcraft/pull/163","diff_url":"https://github.com/ubuntu-core/snapcraft/pull/163.diff","patch_url":"https://github.com/ubuntu-core/snapcraft/pull/163.patch","issue_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/163","number":163,"state":"open","locked":false,"title":"Catkin plugin: use rosdep for dependency resolution","user":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars.githubusercontent.com/u/946674?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"body":"The Catkin plugin currently does its own dependency resolution via manually parsing each package.xml. It makes some naive assumptions while doing so, and a tool already exists in ROS for doing this: rosdep. This PR gets rid of the manual parsing in favor of rosdep.","created_at":"2015-12-11T19:32:27Z","updated_at":"2015-12-17T03:57:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57b83f70b69ed362e3e4a00463649c29c4289070","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163/commits","review_comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163/comments","review_comment_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/163/comments","statuses_url":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/320f122a0a3b4d6613aea887c543e28331e25d0e","head":{"label":"kyrofa:catkin_use_rosdep","ref":"catkin_use_rosdep","sha":"320f122a0a3b4d6613aea887c543e28331e25d0e","user":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars.githubusercontent.com/u/946674?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"repo":{"id":46729716,"name":"snapcraft","full_name":"kyrofa/snapcraft","owner":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars.githubusercontent.com/u/946674?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kyrofa/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":true,"url":"https://api.github.com/repos/kyrofa/snapcraft","forks_url":"https://api.github.com/repos/kyrofa/snapcraft/forks","keys_url":"https://api.github.com/repos/kyrofa/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kyrofa/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kyrofa/snapcraft/teams","hooks_url":"https://api.github.com/repos/kyrofa/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/kyrofa/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/kyrofa/snapcraft/events","assignees_url":"https://api.github.com/repos/kyrofa/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/kyrofa/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/kyrofa/snapcraft/tags","blobs_url":"https://api.github.com/repos/kyrofa/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kyrofa/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kyrofa/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/kyrofa/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kyrofa/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/kyrofa/snapcraft/languages","stargazers_url":"https://api.github.com/repos/kyrofa/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/kyrofa/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/kyrofa/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/kyrofa/snapcraft/subscription","commits_url":"https://api.github.com/repos/kyrofa/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/kyrofa/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/kyrofa/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/kyrofa/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/kyrofa/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/kyrofa/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kyrofa/snapcraft/merges","archive_url":"https://api.github.com/repos/kyrofa/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kyrofa/snapcraft/downloads","issues_url":"https://api.github.com/repos/kyrofa/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/kyrofa/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/kyrofa/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/kyrofa/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kyrofa/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/kyrofa/snapcraft/releases{/id}","created_at":"2015-11-23T15:35:14Z","updated_at":"2015-11-23T15:35:16Z","pushed_at":"2015-12-16T18:38:01Z","git_url":"git://github.com/kyrofa/snapcraft.git","ssh_url":"git@github.com:kyrofa/snapcraft.git","clone_url":"https://github.com/kyrofa/snapcraft.git","svn_url":"https://github.com/kyrofa/snapcraft","homepage":null,"size":2580,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ubuntu-core:master","ref":"master","sha":"3fa5a27f15d5032e926e6b6c5db3c1bd110352f6","user":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"repo":{"id":45199136,"name":"snapcraft","full_name":"ubuntu-core/snapcraft","owner":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubuntu-core/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":false,"url":"https://api.github.com/repos/ubuntu-core/snapcraft","forks_url":"https://api.github.com/repos/ubuntu-core/snapcraft/forks","keys_url":"https://api.github.com/repos/ubuntu-core/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubuntu-core/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubuntu-core/snapcraft/teams","hooks_url":"https://api.github.com/repos/ubuntu-core/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/ubuntu-core/snapcraft/events","assignees_url":"https://api.github.com/repos/ubuntu-core/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/ubuntu-core/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/ubuntu-core/snapcraft/tags","blobs_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/ubuntu-core/snapcraft/languages","stargazers_url":"https://api.github.com/repos/ubuntu-core/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/ubuntu-core/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/ubuntu-core/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/ubuntu-core/snapcraft/subscription","commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubuntu-core/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/ubuntu-core/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubuntu-core/snapcraft/merges","archive_url":"https://api.github.com/repos/ubuntu-core/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubuntu-core/snapcraft/downloads","issues_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/ubuntu-core/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/ubuntu-core/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubuntu-core/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/ubuntu-core/snapcraft/releases{/id}","created_at":"2015-10-29T17:23:15Z","updated_at":"2015-12-13T23:03:37Z","pushed_at":"2015-12-17T03:51:55Z","git_url":"git://github.com/ubuntu-core/snapcraft.git","ssh_url":"git@github.com:ubuntu-core/snapcraft.git","clone_url":"https://github.com/ubuntu-core/snapcraft.git","svn_url":"https://github.com/ubuntu-core/snapcraft","homepage":null,"size":2657,"stargazers_count":23,"watchers_count":23,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":8,"forks":17,"open_issues":8,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/163"},"issue":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/163"},"comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/163/comments"},"review_comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163/comments"},"review_comment":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/163/commits"},"statuses":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/320f122a0a3b4d6613aea887c543e28331e25d0e"}}}}