Merge lp:~sergiusens/snapcraft/1510160 into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov on 2015-10-26
Status: Merged
Approved by: Sergio Schvezov on 2015-10-26
Approved revision: 252
Merged at revision: 253
Proposed branch: lp:~sergiusens/snapcraft/1510160
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 90 lines (+44/-0)
4 files modified
integration-tests/units/jobs.pxu (+6/-0)
snapcraft/cmds.py (+10/-0)
snapcraft/main.py (+6/-0)
snapcraft/tests/test_cmds.py (+22/-0)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/1510160
Reviewer Review Type Date Requested Status
Leo Arias Approve on 2015-10-26
John Lenton 2015-10-26 Approve on 2015-10-26
Review via email: mp+275736@code.launchpad.net

Commit Message

Add list-plugins

To post a comment you must log in.
John Lenton (chipaca) wrote :

LGTM! :)

review: Approve
Leo Arias (elopio) wrote :

The only problem I see is that when you add a new plugin, you will have to change two tests. +1 anyway as that might be a good thing.

I also have a question, what happens if somebody wants to name the plugin my_plugin, with underscore instead of a dash?

review: Approve
Sergio Schvezov (sergiusens) wrote :

> The only problem I see is that when you add a new plugin, you will have to
> change two tests. +1 anyway as that might be a good thing.

This would also break if there is another package that puts stuff here, very dodgy, but possible. I prefer the tight control in some aspects. In the end, 'list-plugins' could also just be a fixed list :-P

> I also have a question, what happens if somebody wants to name the plugin
> my_plugin, with underscore instead of a dash?

It is my question too, we would just need some tight control here. This is the inherited design. We can eventually grab the name from an attribute inside the module.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'integration-tests/units/jobs.pxu'
2--- integration-tests/units/jobs.pxu 2015-10-20 12:20:11 +0000
3+++ integration-tests/units/jobs.pxu 2015-10-26 15:57:33 +0000
4@@ -1,3 +1,9 @@
5+id: snapcraft/normal/list-plugins
6+command:
7+ OUTPUT=$(${SNAPCRAFT} list-plugins)
8+ test "$OUTPUT" = "$(echo -e "ant\nautotools\ncatkin\ncmake\ncopy\ngo\njdk\nmake\nmaven\npython2\npython3\nqml\nroscore\nscons\ntar-content\n")"
9+flags: simple has-leftovers
10+
11 id: snapcraft/normal/no-yaml
12 command:
13 set -x
14
15=== modified file 'snapcraft/cmds.py'
16--- snapcraft/cmds.py 2015-10-21 20:22:42 +0000
17+++ snapcraft/cmds.py 2015-10-26 15:57:33 +0000
18@@ -237,6 +237,16 @@
19 qemu.kill()
20
21
22+def list_plugins(args=None):
23+ import pkgutil
24+ import snapcraft.plugins
25+
26+ for importer, modname, is_package in pkgutil.iter_modules(
27+ snapcraft.plugins.__path__):
28+ if not is_package:
29+ print(modname.replace('_', '-'))
30+
31+
32 def clean(args):
33 config = _load_config()
34
35
36=== modified file 'snapcraft/main.py'
37--- snapcraft/main.py 2015-10-02 09:13:00 +0000
38+++ snapcraft/main.py 2015-10-26 15:57:33 +0000
39@@ -55,6 +55,12 @@
40 parser.set_defaults(func=snapcraft.cmds.run)
41
42 parser = subparsers.add_parser(
43+ 'list-plugins',
44+ help='list the available plugins that handle different types '
45+ 'of a part')
46+ parser.set_defaults(func=snapcraft.cmds.list_plugins)
47+
48+ parser = subparsers.add_parser(
49 'clean',
50 help='clean up the environment (to start from scratch)')
51 parser.set_defaults(func=snapcraft.cmds.clean)
52
53=== modified file 'snapcraft/tests/test_cmds.py'
54--- snapcraft/tests/test_cmds.py 2015-10-08 22:43:48 +0000
55+++ snapcraft/tests/test_cmds.py 2015-10-26 15:57:33 +0000
56@@ -14,6 +14,7 @@
57 # You should have received a copy of the GNU General Public License
58 # along with this program. If not, see <http://www.gnu.org/licenses/>.
59
60+import io
61 import logging
62 import os
63 import tempfile
64@@ -79,6 +80,27 @@
65 ' a/2\n',
66 fake_logger.output)
67
68+ @mock.patch('sys.stdout', new_callable=io.StringIO)
69+ def test_list_plugins(self, mock_stdout):
70+ expected_list = '''ant
71+autotools
72+catkin
73+cmake
74+copy
75+go
76+jdk
77+make
78+maven
79+python2
80+python3
81+qml
82+roscore
83+scons
84+tar-content
85+'''
86+ cmds.list_plugins()
87+ self.assertEqual(mock_stdout.getvalue(), expected_list)
88+
89
90 class CleanTestCase(tests.TestCase):
91

Subscribers

People subscribed via source and target branches