{"action":"created","comment":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/49801580","id":49801580,"diff_hunk":"@@ -447,19 +447,50 @@ def test_prepare_build(self):\n     @mock.patch.object(catkin.CatkinPlugin, 'run_output', return_value='foo')\n     def test_finish_build(self, run_output_mock, run_mock):\n         plugin = catkin.CatkinPlugin('test-part', self.properties)\n-        os.makedirs(plugin.rosdir)\n+        os.makedirs(os.path.join(plugin.rosdir, 'bin'))\n+        os.makedirs(os.path.join(plugin.rosdir, 'etc', 'catkin', 'profile.d'))\n+\n+        shebang_file1 = os.path.join(plugin.rosdir, '_setup_util.py')\n+        shebang_file2 = os.path.join(plugin.rosdir, 'bin', 'catkin_find')\n \n-        # Place _setup_util.py with a bad shebang\n-        with open(os.path.join(plugin.rosdir, '_setup_util.py'), 'w') as f:\n+        # Place a few files with bad shebangs\n+        with open(shebang_file1, 'w') as f:\n             f.write('#!/foo/bar/baz/python')\n+        with open(shebang_file2, 'w') as f:\n+            f.write('#!/foo/baz/python')\n+\n+        # Place a file with no shebang\n+        irrelevant_file = os.path.join(plugin.rosdir, 'foo')\n+        with open(irrelevant_file, 'w') as f:\n+            f.write('foo')\n+\n+        ros_profile = os.path.join(plugin.rosdir, 'etc', 'catkin', 'profile.d',\n+                                   '10.ros.sh')\n+\n+        # Place 10.ros.sh with an absolute path to python\n+        with open(ros_profile, 'w') as f:\n+            f.write('/usr/bin/python foo')\n \n         plugin._finish_build()\n \n-        # Verify that _setup_util.py had its shebang rewritten correctly\n-        with open('{}/_setup_util.py'.format(\n-                plugin.rosdir), 'r') as f:\n-            self.assertEqual(f.read(), '#!/usr/bin/env python',\n-                             'The shebang was not replaced as expected')\n+        # Verify that the shebangs were rewritten correctly\n+        for shebang_file in [shebang_file1, shebang_file2]:\n+            with open(shebang_file, 'r') as f:\n+                self.assertEqual(f.read(), '#!/usr/bin/env python',\n+                                 'The shebang in \"{}\" was not replaced as '\n+                                 'expected'.format(shebang_file))\n+\n+        # Verify that the irrelevant file wasn't touched\n+        with open(irrelevant_file, 'r') as f:\n+            self.assertEqual(f.read(), 'foo',\n+                             'Expected the contents of \"{}\" to remain '\n+                             'unchanged.'.format(irrelevant_file))\n+\n+        # Verify that the absolute path in 10.ros.sh was rewritten correctly\n+        with open(ros_profile, 'r') as f:\n+            self.assertEqual(f.read(), 'python foo',\n+                             'The absolute path to python was not replaced as '\n+                             'expected')","path":"snapcraft/tests/test_plugin_catkin.py","position":55,"original_position":55,"commit_id":"bf88521b3000e63fc2bd449482f318457bca3854","original_commit_id":"bf88521b3000e63fc2bd449482f318457bca3854","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":"Huge test. What about making one test per #Verify comment?","created_at":"2016-01-14T23:26:04Z","updated_at":"2016-01-14T23:26:04Z","html_url":"https://github.com/ubuntu-core/snapcraft/pull/232#discussion_r49801580","pull_request_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232","_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/49801580"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/232#discussion_r49801580"},"pull_request":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232"}}},"pull_request":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232","id":56106369,"html_url":"https://github.com/ubuntu-core/snapcraft/pull/232","diff_url":"https://github.com/ubuntu-core/snapcraft/pull/232.diff","patch_url":"https://github.com/ubuntu-core/snapcraft/pull/232.patch","issue_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/232","number":232,"state":"open","locked":false,"title":"Catkin plugin: Use in-snap python instead of OS-provided.","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":"This works pre-Xenial since python2 is provided on the image. However, it's been removed in Xenial which uncovered this bug. The fix simply rewrites all /usr/bin/python shebangs to use /usr/bin/env python, and also fixes up 10.ros.sh to use python from the path instead of /usr/bin/python.\r\n\r\nLP: [#1533297](https://bugs.launchpad.net/snapcraft/+bug/1533297)","created_at":"2016-01-14T22:52:10Z","updated_at":"2016-01-14T23:26:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bb6ea09775f2187b2a110aefec047c2682af6c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232/commits","review_comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232/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/232/comments","statuses_url":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/bf88521b3000e63fc2bd449482f318457bca3854","head":{"label":"kyrofa:bugfix/1533297/catkin_run_on_rolling","ref":"bugfix/1533297/catkin_run_on_rolling","sha":"bf88521b3000e63fc2bd449482f318457bca3854","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-12-21T19:47:29Z","pushed_at":"2016-01-14T23:09:11Z","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":2745,"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":"8553f86975e4034b2646afe810cab39718117400","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":"2016-01-12T17:25:54Z","pushed_at":"2016-01-14T23:09:12Z","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":2849,"stargazers_count":32,"watchers_count":32,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":12,"forks":26,"open_issues":12,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/232"},"issue":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/232"},"comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/232/comments"},"review_comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/232/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/232/commits"},"statuses":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/bf88521b3000e63fc2bd449482f318457bca3854"}}}}