Merge lp:~sergiusens/snapcraft/mapnames into lp:~snappy-dev/snapcraft/core
- mapnames
- Merge into core
Proposed by
Sergio Schvezov
Status: | Merged |
---|---|
Approved by: | Sergio Schvezov |
Approved revision: | 185 |
Merged at revision: | 185 |
Proposed branch: | lp:~sergiusens/snapcraft/mapnames |
Merge into: | lp:~snappy-dev/snapcraft/core |
Diff against target: |
517 lines (+97/-142) 15 files modified
examples/downloader-with-wiki-parts/snapcraft.yaml (+2/-1) examples/godd/snapcraft.yaml (+2/-1) examples/gopaste/snapcraft.yaml (+1/-1) examples/java-hello-world/snapcraft.yaml (+1/-1) examples/libpipeline/snapcraft.yaml (+2/-1) examples/py2-project/snapcraft.yaml (+2/-1) examples/py3-project/snapcraft.yaml (+2/-1) examples/qmldemo/snapcraft.yaml (+1/-1) examples/tomcat-maven-webapp/snapcraft.yaml (+1/-1) examples/webcam-webui/snapcraft.yaml (+1/-1) integration-tests/data/assemble/snapcraft.yaml (+5/-5) schema/snapcraft.yaml (+13/-16) snapcraft/meta.py (+22/-16) snapcraft/tests/test_meta.py (+24/-66) snapcraft/tests/test_yaml.py (+18/-29) |
To merge this branch: | bzr merge lp:~sergiusens/snapcraft/mapnames |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sergio Schvezov | Approve | ||
Daniel Holbach | Pending | ||
Michael Vogt | Pending | ||
Review via email: mp+271799@code.launchpad.net |
This proposal supersedes a proposal from 2015-09-21.
Commit message
Using a map instead of list for binaries and services as defined by the spec
Description of the change
To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal | # |
review:
Approve
Revision history for this message
Michael Vogt (mvo) wrote : Posted in a previous version of this proposal | # |
Looks good.
review:
Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote : Posted in a previous version of this proposal | # |
More than one proposal found for merge of https:/
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote : Posted in a previous version of this proposal | # |
More than one proposal found for merge of https:/
Revision history for this message
Sergio Schvezov (sergiusens) wrote : | # |
I resubmitted to get rid of the tarmac issue
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'examples/downloader-with-wiki-parts/snapcraft.yaml' | |||
2 | --- examples/downloader-with-wiki-parts/snapcraft.yaml 2015-09-15 15:20:24 +0000 | |||
3 | +++ examples/downloader-with-wiki-parts/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
4 | @@ -5,7 +5,8 @@ | |||
5 | 5 | description: this is an example package | 5 | description: this is an example package |
6 | 6 | icon: icon.png | 6 | icon: icon.png |
7 | 7 | binaries: | 7 | binaries: |
9 | 8 | - name: bin/test | 8 | test: |
10 | 9 | exec: bin/test | ||
11 | 9 | 10 | ||
12 | 10 | parts: | 11 | parts: |
13 | 11 | main: | 12 | main: |
14 | 12 | 13 | ||
15 | === modified file 'examples/godd/snapcraft.yaml' | |||
16 | --- examples/godd/snapcraft.yaml 2015-09-18 14:53:03 +0000 | |||
17 | +++ examples/godd/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
18 | @@ -2,7 +2,8 @@ | |||
19 | 2 | version: 1.0 | 2 | version: 1.0 |
20 | 3 | vendor: Michael Vogt <mvo@ubuntu.com> | 3 | vendor: Michael Vogt <mvo@ubuntu.com> |
21 | 4 | binaries: | 4 | binaries: |
23 | 5 | - name: ./bin/godd | 5 | godd: |
24 | 6 | exec: ./bin/godd | ||
25 | 6 | summary: Simple dd like tool | 7 | summary: Simple dd like tool |
26 | 7 | description: written in go so it is self contained and really portable, you would need to use hw-assign to access devices. | 8 | description: written in go so it is self contained and really portable, you would need to use hw-assign to access devices. |
27 | 8 | icon: icon.png | 9 | icon: icon.png |
28 | 9 | 10 | ||
29 | === modified file 'examples/gopaste/snapcraft.yaml' | |||
30 | --- examples/gopaste/snapcraft.yaml 2015-09-08 21:06:47 +0000 | |||
31 | +++ examples/gopaste/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
32 | @@ -2,7 +2,7 @@ | |||
33 | 2 | version: 1.0 | 2 | version: 1.0 |
34 | 3 | vendor: Michael Terry <mterry@ubuntu.com> | 3 | vendor: Michael Terry <mterry@ubuntu.com> |
35 | 4 | services: | 4 | services: |
37 | 5 | - name: gopaste | 5 | gopaste: |
38 | 6 | description: "gopaste" | 6 | description: "gopaste" |
39 | 7 | start: bin/gopasted | 7 | start: bin/gopasted |
40 | 8 | summary: Simple pasting tool | 8 | summary: Simple pasting tool |
41 | 9 | 9 | ||
42 | === modified file 'examples/java-hello-world/snapcraft.yaml' | |||
43 | --- examples/java-hello-world/snapcraft.yaml 2015-09-15 09:43:13 +0000 | |||
44 | +++ examples/java-hello-world/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
45 | @@ -2,7 +2,7 @@ | |||
46 | 2 | version: 0 | 2 | version: 0 |
47 | 3 | vendor: Michael Terry <mterry@ubuntu.com> | 3 | vendor: Michael Terry <mterry@ubuntu.com> |
48 | 4 | binaries: | 4 | binaries: |
50 | 5 | - name: hello | 5 | hello: |
51 | 6 | exec: bin/wrapper | 6 | exec: bin/wrapper |
52 | 7 | summary: A java example | 7 | summary: A java example |
53 | 8 | description: this is not much more than an example | 8 | description: this is not much more than an example |
54 | 9 | 9 | ||
55 | === modified file 'examples/libpipeline/snapcraft.yaml' | |||
56 | --- examples/libpipeline/snapcraft.yaml 2015-09-08 11:48:30 +0000 | |||
57 | +++ examples/libpipeline/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
58 | @@ -2,7 +2,8 @@ | |||
59 | 2 | version: 1.0 | 2 | version: 1.0 |
60 | 3 | vendor: Mike Terry <mterry@ubuntu.com> | 3 | vendor: Mike Terry <mterry@ubuntu.com> |
61 | 4 | binaries: | 4 | binaries: |
63 | 5 | - name: ./bin/pipelinetest | 5 | pipelinetest: |
64 | 6 | exec: ./bin/pipelinetest | ||
65 | 6 | summary: Libpipeline example | 7 | summary: Libpipeline example |
66 | 7 | description: this is an example package of an autotools project built with snapcraft using | 8 | description: this is an example package of an autotools project built with snapcraft using |
67 | 8 | icon: icon.png | 9 | icon: icon.png |
68 | 9 | 10 | ||
69 | === modified file 'examples/py2-project/snapcraft.yaml' | |||
70 | --- examples/py2-project/snapcraft.yaml 2015-09-08 11:48:30 +0000 | |||
71 | +++ examples/py2-project/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
72 | @@ -2,7 +2,8 @@ | |||
73 | 2 | version: 0 | 2 | version: 0 |
74 | 3 | vendor: Michael Vogt <michael.vogt@ubuntu.com> | 3 | vendor: Michael Vogt <michael.vogt@ubuntu.com> |
75 | 4 | binaries: | 4 | binaries: |
77 | 5 | - name: ./bin/sha3sum | 5 | sha3sum: |
78 | 6 | exec: ./bin/sha3sum | ||
79 | 6 | summary: A python sha3 implementation | 7 | summary: A python sha3 implementation |
80 | 7 | description: A python2 project using snapcraft | 8 | description: A python2 project using snapcraft |
81 | 8 | icon: icon.png | 9 | icon: icon.png |
82 | 9 | 10 | ||
83 | === modified file 'examples/py3-project/snapcraft.yaml' | |||
84 | --- examples/py3-project/snapcraft.yaml 2015-09-08 11:48:30 +0000 | |||
85 | +++ examples/py3-project/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
86 | @@ -2,7 +2,8 @@ | |||
87 | 2 | version: 0 | 2 | version: 0 |
88 | 3 | vendor: Michael Vogt <michael.vogt@ubuntu.com> | 3 | vendor: Michael Vogt <michael.vogt@ubuntu.com> |
89 | 4 | binaries: | 4 | binaries: |
91 | 5 | - name: bin/sha3sum | 5 | sha3sum: |
92 | 6 | exec: bin/sha3sum | ||
93 | 6 | summary: A python sha3 implementation | 7 | summary: A python sha3 implementation |
94 | 7 | description: A python2 project using snapcraft | 8 | description: A python2 project using snapcraft |
95 | 8 | icon: icon.png | 9 | icon: icon.png |
96 | 9 | 10 | ||
97 | === modified file 'examples/qmldemo/snapcraft.yaml' | |||
98 | --- examples/qmldemo/snapcraft.yaml 2015-09-08 11:50:21 +0000 | |||
99 | +++ examples/qmldemo/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
100 | @@ -4,7 +4,7 @@ | |||
101 | 4 | frameworks: | 4 | frameworks: |
102 | 5 | - mir | 5 | - mir |
103 | 6 | binaries: | 6 | binaries: |
105 | 7 | - name: qmldemo | 7 | qmldemo: |
106 | 8 | exec: qmlscene demo.qml -- | 8 | exec: qmlscene demo.qml -- |
107 | 9 | caps: | 9 | caps: |
108 | 10 | - mir_client | 10 | - mir_client |
109 | 11 | 11 | ||
110 | === modified file 'examples/tomcat-maven-webapp/snapcraft.yaml' | |||
111 | --- examples/tomcat-maven-webapp/snapcraft.yaml 2015-09-08 11:50:21 +0000 | |||
112 | +++ examples/tomcat-maven-webapp/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
113 | @@ -4,7 +4,7 @@ | |||
114 | 4 | architectures: | 4 | architectures: |
115 | 5 | - amd64 | 5 | - amd64 |
116 | 6 | services: | 6 | services: |
118 | 7 | - name: tomcat | 7 | tomcat: |
119 | 8 | start: bin/wrapper | 8 | start: bin/wrapper |
120 | 9 | caps: | 9 | caps: |
121 | 10 | - networking | 10 | - networking |
122 | 11 | 11 | ||
123 | === modified file 'examples/webcam-webui/snapcraft.yaml' | |||
124 | --- examples/webcam-webui/snapcraft.yaml 2015-09-20 14:34:08 +0000 | |||
125 | +++ examples/webcam-webui/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
126 | @@ -5,7 +5,7 @@ | |||
127 | 5 | description: Exposes your webcam over a web UI | 5 | description: Exposes your webcam over a web UI |
128 | 6 | icon: icon.png | 6 | icon: icon.png |
129 | 7 | services: | 7 | services: |
131 | 8 | - name: webcam-webui | 8 | webcam-webui: |
132 | 9 | start: bin/webcam-webui | 9 | start: bin/webcam-webui |
133 | 10 | config: usr/bin/config.py | 10 | config: usr/bin/config.py |
134 | 11 | 11 | ||
135 | 12 | 12 | ||
136 | === modified file 'integration-tests/data/assemble/snapcraft.yaml' | |||
137 | --- integration-tests/data/assemble/snapcraft.yaml 2015-09-01 19:04:49 +0000 | |||
138 | +++ integration-tests/data/assemble/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
139 | @@ -5,12 +5,12 @@ | |||
140 | 5 | description: a longer description | 5 | description: a longer description |
141 | 6 | icon: icon.png | 6 | icon: icon.png |
142 | 7 | binaries: | 7 | binaries: |
147 | 8 | - exec: binary1 | 8 | assemble-bin: |
148 | 9 | name: assemble-bin | 9 | exec: binary1 |
149 | 10 | - exec: subdir/binary2 | 10 | binary2: |
150 | 11 | name: binary2 | 11 | exec: subdir/binary2 |
151 | 12 | services: | 12 | services: |
153 | 13 | - name: assemble-service | 13 | assemble-service: |
154 | 14 | start: service-start | 14 | start: service-start |
155 | 15 | stop: service-stop with args | 15 | stop: service-stop with args |
156 | 16 | 16 | ||
157 | 17 | 17 | ||
158 | === modified file 'schema/snapcraft.yaml' | |||
159 | --- schema/snapcraft.yaml 2015-09-16 19:31:05 +0000 | |||
160 | +++ schema/snapcraft.yaml 2015-09-21 11:41:30 +0000 | |||
161 | @@ -56,16 +56,14 @@ | |||
162 | 56 | type: string | 56 | type: string |
163 | 57 | description: path to a configure hook to expose configuration for the package | 57 | description: path to a configure hook to expose configuration for the package |
164 | 58 | services: | 58 | services: |
168 | 59 | type: array | 59 | type: object |
169 | 60 | items: | 60 | additionalProperties: false |
170 | 61 | - type: object | 61 | patternProperties: |
171 | 62 | "^[A-Za-z0-9:-]*$": | ||
172 | 63 | type: object | ||
173 | 62 | required: | 64 | required: |
174 | 63 | - name | ||
175 | 64 | - start | 65 | - start |
176 | 65 | properties: | 66 | properties: |
177 | 66 | name: | ||
178 | 67 | type: string | ||
179 | 68 | pattern: "^[A-Za-z0-9/.:-]*$" | ||
180 | 69 | start: | 67 | start: |
181 | 70 | type: string | 68 | type: string |
182 | 71 | description: command executed to start the service | 69 | description: command executed to start the service |
183 | @@ -77,18 +75,17 @@ | |||
184 | 77 | security-override: | 75 | security-override: |
185 | 78 | $ref: "#definitions/security" | 76 | $ref: "#definitions/security" |
186 | 79 | binaries: | 77 | binaries: |
190 | 80 | type: array | 78 | type: object |
191 | 81 | items: | 79 | additionalProperties: false |
192 | 82 | - type: object | 80 | patternProperties: |
193 | 81 | "^[A-Za-z0-9:-]*$": | ||
194 | 82 | type: object | ||
195 | 83 | required: | 83 | required: |
197 | 84 | - name | 84 | - exec |
198 | 85 | properties: | 85 | properties: |
199 | 86 | name: | ||
200 | 87 | type: string | ||
201 | 88 | pattern: "^[A-Za-z0-9/.:-]*$" | ||
202 | 89 | exec: | 86 | exec: |
203 | 90 | type: string | 87 | type: string |
205 | 91 | description: command executed to start the service | 88 | description: command executed to run the binary |
206 | 92 | security-policy: | 89 | security-policy: |
207 | 93 | $ref: "#definitions/security" | 90 | $ref: "#definitions/security" |
208 | 94 | security-override: | 91 | security-override: |
209 | @@ -96,6 +93,7 @@ | |||
210 | 96 | parts: | 93 | parts: |
211 | 97 | type: object | 94 | type: object |
212 | 98 | minProperties: 1 | 95 | minProperties: 1 |
213 | 96 | additionalProperties: false | ||
214 | 99 | patternProperties: | 97 | patternProperties: |
215 | 100 | ^[a-z0-9][a-z0-9+-]*$: | 98 | ^[a-z0-9][a-z0-9+-]*$: |
216 | 101 | type: object | 99 | type: object |
217 | @@ -116,7 +114,6 @@ | |||
218 | 116 | # required: | 114 | # required: |
219 | 117 | # - plugin | 115 | # - plugin |
220 | 118 | # - source | 116 | # - source |
221 | 119 | addtionalProperties: false | ||
222 | 120 | required: | 117 | required: |
223 | 121 | - name | 118 | - name |
224 | 122 | - version | 119 | - version |
225 | 123 | 120 | ||
226 | === modified file 'snapcraft/meta.py' | |||
227 | --- snapcraft/meta.py 2015-09-16 19:31:05 +0000 | |||
228 | +++ snapcraft/meta.py 2015-09-21 11:41:30 +0000 | |||
229 | @@ -130,16 +130,26 @@ | |||
230 | 130 | package_yaml['architectures'] = arches | 130 | package_yaml['architectures'] = arches |
231 | 131 | 131 | ||
232 | 132 | if 'binaries' in config_data: | 132 | if 'binaries' in config_data: |
235 | 133 | package_yaml['binaries'] = _wrap_binaries(config_data['binaries']) | 133 | binaries = config_data['binaries'] |
236 | 134 | package_yaml['binaries'] = _copy_security_profiles(meta_dir, config_data['binaries']) | 134 | binaries = _wrap_binaries(binaries) |
237 | 135 | package_yaml['binaries'] = _copy_security_profiles(meta_dir, _repack_names(binaries)) | ||
238 | 135 | 136 | ||
239 | 136 | if 'services' in config_data: | 137 | if 'services' in config_data: |
242 | 137 | package_yaml['services'] = _wrap_services(config_data['services']) | 138 | services = config_data['services'] |
243 | 138 | package_yaml['services'] = _copy_security_profiles(meta_dir, config_data['services']) | 139 | services = _wrap_services(services) |
244 | 140 | package_yaml['services'] = _copy_security_profiles(meta_dir, _repack_names(services)) | ||
245 | 139 | 141 | ||
246 | 140 | return package_yaml | 142 | return package_yaml |
247 | 141 | 143 | ||
248 | 142 | 144 | ||
249 | 145 | def _repack_names(names): | ||
250 | 146 | repack = [] | ||
251 | 147 | for name in names: | ||
252 | 148 | names[name].update({'name': name}) | ||
253 | 149 | repack.append(names[name]) | ||
254 | 150 | return repack | ||
255 | 151 | |||
256 | 152 | |||
257 | 143 | def _compose_readme(config_data): | 153 | def _compose_readme(config_data): |
258 | 144 | return '{config[summary]}\n{config[description]}\n'.format(config=config_data) | 154 | return '{config[summary]}\n{config[description]}\n'.format(config=config_data) |
259 | 145 | 155 | ||
260 | @@ -199,29 +209,25 @@ | |||
261 | 199 | 209 | ||
262 | 200 | 210 | ||
263 | 201 | def _wrap_binaries(binaries): | 211 | def _wrap_binaries(binaries): |
266 | 202 | for binary in binaries: | 212 | for name in binaries: |
267 | 203 | execparts = shlex.split(binary.get('exec', binary['name'])) | 213 | execparts = shlex.split(binaries[name]['exec']) |
268 | 204 | execwrap = _wrap_exe(execparts[0]) | 214 | execwrap = _wrap_exe(execparts[0]) |
274 | 205 | if 'exec' in binary: | 215 | binaries[name]['exec'] = _replace_cmd(execparts, execwrap) |
270 | 206 | binary['exec'] = _replace_cmd(execparts, execwrap) | ||
271 | 207 | else: | ||
272 | 208 | binary['name'] = os.path.basename(binary['name']) | ||
273 | 209 | binary['exec'] = _replace_cmd(execparts, execwrap) | ||
275 | 210 | 216 | ||
276 | 211 | return binaries | 217 | return binaries |
277 | 212 | 218 | ||
278 | 213 | 219 | ||
279 | 214 | def _wrap_services(services): | 220 | def _wrap_services(services): |
282 | 215 | for binary in services: | 221 | for name in services: |
283 | 216 | startpath = binary.get('start') | 222 | startpath = services[name].get('start') |
284 | 217 | if startpath: | 223 | if startpath: |
285 | 218 | startparts = shlex.split(startpath) | 224 | startparts = shlex.split(startpath) |
286 | 219 | startwrap = _wrap_exe(startparts[0]) | 225 | startwrap = _wrap_exe(startparts[0]) |
289 | 220 | binary['start'] = _replace_cmd(startparts, startwrap) | 226 | services[name]['start'] = _replace_cmd(startparts, startwrap) |
290 | 221 | stoppath = binary.get('stop') | 227 | stoppath = services[name].get('stop') |
291 | 222 | if stoppath: | 228 | if stoppath: |
292 | 223 | stopparts = shlex.split(stoppath) | 229 | stopparts = shlex.split(stoppath) |
293 | 224 | stopwrap = _wrap_exe(stopparts[0]) | 230 | stopwrap = _wrap_exe(stopparts[0]) |
295 | 225 | binary['stop'] = _replace_cmd(stopparts, stopwrap) | 231 | services[name]['stop'] = _replace_cmd(stopparts, stopwrap) |
296 | 226 | 232 | ||
297 | 227 | return services | 233 | return services |
298 | 228 | 234 | ||
299 | === modified file 'snapcraft/tests/test_meta.py' | |||
300 | --- snapcraft/tests/test_meta.py 2015-09-16 19:31:05 +0000 | |||
301 | +++ snapcraft/tests/test_meta.py 2015-09-21 11:41:30 +0000 | |||
302 | @@ -69,79 +69,38 @@ | |||
303 | 69 | self.assertEqual(y, expected) | 69 | self.assertEqual(y, expected) |
304 | 70 | 70 | ||
305 | 71 | def test_with_binaries(self): | 71 | def test_with_binaries(self): |
315 | 72 | self.config_data['binaries'] = [ | 72 | self.config_data['binaries'] = { |
316 | 73 | { | 73 | 'binary1': {'exec': 'binary1.sh go'}, |
317 | 74 | 'name': 'binary1', | 74 | 'binary2': {'exec': 'binary2.sh'}, |
318 | 75 | 'exec': 'binary1.sh go', | 75 | } |
310 | 76 | }, | ||
311 | 77 | { | ||
312 | 78 | 'name': 'binary2', | ||
313 | 79 | }, | ||
314 | 80 | ] | ||
319 | 81 | 76 | ||
320 | 82 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 77 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) |
321 | 83 | 78 | ||
341 | 84 | expected = { | 79 | self.assertEqual(len(y['binaries']), 2) |
342 | 85 | 'name': 'my-package', | 80 | for b in y['binaries']: |
343 | 86 | 'version': '1.0', | 81 | if b['name'] is 'binary1': |
344 | 87 | 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', | 82 | self.assertEqual(b['exec'], 'binary.wrapped go') |
345 | 88 | 'icon': 'my-icon.png', | 83 | else: |
346 | 89 | 'architectures': ['armhf', 'amd64'], | 84 | self.assertEqual(b['exec'], 'binary.wrapped') |
328 | 90 | 'binaries': [ | ||
329 | 91 | { | ||
330 | 92 | 'name': 'binary1', | ||
331 | 93 | 'exec': 'binary.wrapped go', | ||
332 | 94 | }, | ||
333 | 95 | { | ||
334 | 96 | 'name': 'binary2', | ||
335 | 97 | 'exec': 'binary.wrapped', | ||
336 | 98 | }, | ||
337 | 99 | ], | ||
338 | 100 | } | ||
339 | 101 | |||
340 | 102 | self.assertEqual(y, expected) | ||
347 | 103 | 85 | ||
348 | 104 | def test_with_services(self): | 86 | def test_with_services(self): |
356 | 105 | self.config_data['services'] = [ | 87 | self.config_data['services'] = { |
357 | 106 | { | 88 | 'service1': {'start': 'binary1'}, |
358 | 107 | 'name': 'service1', | 89 | 'service2': { |
352 | 108 | 'start': 'binary1', | ||
353 | 109 | }, | ||
354 | 110 | { | ||
355 | 111 | 'name': 'service2', | ||
359 | 112 | 'start': 'binary2 --start', | 90 | 'start': 'binary2 --start', |
360 | 113 | 'stop': 'binary2 --stop', | 91 | 'stop': 'binary2 --stop', |
361 | 114 | }, | 92 | }, |
366 | 115 | { | 93 | } |
363 | 116 | 'name': 'service3', | ||
364 | 117 | }, | ||
365 | 118 | ] | ||
367 | 119 | 94 | ||
368 | 120 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) | 95 | y = meta._compose_package_yaml('meta', self.config_data, ['armhf', 'amd64']) |
369 | 121 | 96 | ||
393 | 122 | expected = { | 97 | self.assertEqual(len(y['services']), 2) |
394 | 123 | 'name': 'my-package', | 98 | for b in y['services']: |
395 | 124 | 'version': '1.0', | 99 | if b['name'] is 'service1': |
396 | 125 | 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', | 100 | self.assertEqual(b['start'], 'binary.wrapped') |
397 | 126 | 'icon': 'my-icon.png', | 101 | else: |
398 | 127 | 'architectures': ['armhf', 'amd64'], | 102 | self.assertEqual(b['start'], 'binary.wrapped --start') |
399 | 128 | 'services': [ | 103 | self.assertEqual(b['stop'], 'binary.wrapped --stop') |
377 | 129 | { | ||
378 | 130 | 'name': 'service1', | ||
379 | 131 | 'start': 'binary.wrapped', | ||
380 | 132 | }, | ||
381 | 133 | { | ||
382 | 134 | 'name': 'service2', | ||
383 | 135 | 'start': 'binary.wrapped --start', | ||
384 | 136 | 'stop': 'binary.wrapped --stop', | ||
385 | 137 | }, | ||
386 | 138 | { | ||
387 | 139 | 'name': 'service3', | ||
388 | 140 | } | ||
389 | 141 | ], | ||
390 | 142 | } | ||
391 | 143 | |||
392 | 144 | self.assertEqual(y, expected) | ||
400 | 145 | 104 | ||
401 | 146 | def test_plain_no_binaries_or_services_with_optionals(self): | 105 | def test_plain_no_binaries_or_services_with_optionals(self): |
402 | 147 | self.config_data['frameworks'] = ['mir', ] | 106 | self.config_data['frameworks'] = ['mir', ] |
403 | @@ -200,16 +159,15 @@ | |||
404 | 200 | 'summary': 'my summary', | 159 | 'summary': 'my summary', |
405 | 201 | 'icon': 'my-icon.png', | 160 | 'icon': 'my-icon.png', |
406 | 202 | 'config': 'bin/config', | 161 | 'config': 'bin/config', |
410 | 203 | 'binaries': [ | 162 | 'binaries': { |
411 | 204 | { | 163 | 'bash': { |
409 | 205 | 'name': 'bash', | ||
412 | 206 | 'exec': 'bin/bash', | 164 | 'exec': 'bin/bash', |
413 | 207 | 'security-policy': { | 165 | 'security-policy': { |
414 | 208 | 'apparmor': 'file.apparmor', | 166 | 'apparmor': 'file.apparmor', |
415 | 209 | 'seccomp': 'file.seccomp', | 167 | 'seccomp': 'file.seccomp', |
416 | 210 | }, | 168 | }, |
417 | 211 | } | 169 | } |
419 | 212 | ] | 170 | } |
420 | 213 | } | 171 | } |
421 | 214 | 172 | ||
422 | 215 | self.meta_dir = os.path.join(os.path.abspath(os.curdir), 'snap', 'meta') | 173 | self.meta_dir = os.path.join(os.path.abspath(os.curdir), 'snap', 'meta') |
423 | 216 | 174 | ||
424 | === modified file 'snapcraft/tests/test_yaml.py' | |||
425 | --- snapcraft/tests/test_yaml.py 2015-09-15 14:45:57 +0000 | |||
426 | +++ snapcraft/tests/test_yaml.py 2015-09-21 11:41:30 +0000 | |||
427 | @@ -369,72 +369,61 @@ | |||
428 | 369 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 369 | self.assertEqual(raised.exception.message, expected_message, msg=data) |
429 | 370 | 370 | ||
430 | 371 | def test_valid_services(self): | 371 | def test_valid_services(self): |
438 | 372 | self.data['services'] = [ | 372 | self.data['services'] = { |
439 | 373 | { | 373 | 'service1': {'start': 'binary1 start'}, |
440 | 374 | 'name': 'service1', | 374 | 'service2': { |
434 | 375 | 'start': 'binary1 start', | ||
435 | 376 | }, | ||
436 | 377 | { | ||
437 | 378 | 'name': 'service2', | ||
441 | 379 | 'start': 'binary2', | 375 | 'start': 'binary2', |
442 | 380 | 'stop': 'binary2 --stop', | 376 | 'stop': 'binary2 --stop', |
443 | 381 | }, | 377 | }, |
448 | 382 | { | 378 | } |
445 | 383 | 'name': 'service3', | ||
446 | 384 | } | ||
447 | 385 | ] | ||
449 | 386 | 379 | ||
450 | 387 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 380 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
451 | 388 | 381 | ||
452 | 389 | def test_invalid_binary_names(self): | 382 | def test_invalid_binary_names(self): |
453 | 390 | invalid_names = { | 383 | invalid_names = { |
458 | 391 | '#': {'name': 'qwe#rty', 'exec': '1'}, | 384 | 'qwe#rty': {'exec': '1'}, |
459 | 392 | '_': {'name': 'qwe_rty', 'exec': '1'}, | 385 | 'qwe_rty': {'exec': '1'}, |
460 | 393 | 'space': {'name': 'qwe rty', 'exec': '1'}, | 386 | 'que rty': {'exec': '1'}, |
461 | 394 | 'spaces': {'name': 'qwe rty', 'exec': '1'}, | 387 | 'que rty': {'exec': '1'}, |
462 | 395 | } | 388 | } |
463 | 396 | 389 | ||
464 | 397 | for t in invalid_names: | 390 | for t in invalid_names: |
465 | 398 | data = self.data.copy() | 391 | data = self.data.copy() |
466 | 399 | with self.subTest(key=t): | 392 | with self.subTest(key=t): |
468 | 400 | data['binaries'] = [invalid_names[t]] | 393 | data['binaries'] = {t: invalid_names[t]} |
469 | 401 | 394 | ||
470 | 402 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 395 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
471 | 403 | snapcraft.yaml._validate_snapcraft_yaml(data) | 396 | snapcraft.yaml._validate_snapcraft_yaml(data) |
472 | 404 | 397 | ||
474 | 405 | expected_message = '\'{}\' does not match \'^[A-Za-z0-9/.:-]*$\''.format(invalid_names[t]['name']) | 398 | expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t) |
475 | 406 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 399 | self.assertEqual(raised.exception.message, expected_message, msg=data) |
476 | 407 | 400 | ||
477 | 408 | def test_invalid_service_names(self): | 401 | def test_invalid_service_names(self): |
478 | 409 | invalid_names = { | 402 | invalid_names = { |
483 | 410 | '#': {'name': 'qwe#rty', 'start': '1'}, | 403 | 'qwe#rty': {'start': '1'}, |
484 | 411 | '_': {'name': 'qwe_rty', 'start': '1'}, | 404 | 'qwe_rty': {'start': '1'}, |
485 | 412 | 'space': {'name': 'qwe rty', 'start': '1'}, | 405 | 'que_rty': {'start': '1'}, |
486 | 413 | 'spaces': {'name': 'qwe rty', 'start': '1'}, | 406 | 'quer ty': {'start': '1'}, |
487 | 414 | } | 407 | } |
488 | 415 | 408 | ||
489 | 416 | for t in invalid_names: | 409 | for t in invalid_names: |
490 | 417 | data = self.data.copy() | 410 | data = self.data.copy() |
491 | 418 | with self.subTest(key=t): | 411 | with self.subTest(key=t): |
493 | 419 | data['services'] = [invalid_names[t]] | 412 | data['services'] = {t: invalid_names[t]} |
494 | 420 | 413 | ||
495 | 421 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 414 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
496 | 422 | snapcraft.yaml._validate_snapcraft_yaml(data) | 415 | snapcraft.yaml._validate_snapcraft_yaml(data) |
497 | 423 | 416 | ||
499 | 424 | expected_message = '\'{}\' does not match \'^[A-Za-z0-9/.:-]*$\''.format(invalid_names[t]['name']) | 417 | expected_message = 'Additional properties are not allowed (\'{}\' was unexpected)'.format(t) |
500 | 425 | self.assertEqual(raised.exception.message, expected_message, msg=data) | 418 | self.assertEqual(raised.exception.message, expected_message, msg=data) |
501 | 426 | 419 | ||
502 | 427 | def test_services_required_properties(self): | 420 | def test_services_required_properties(self): |
508 | 428 | self.data['services'] = [ | 421 | self.data['services'] = {'service1': {}} |
504 | 429 | { | ||
505 | 430 | 'start': 'binary1 start', | ||
506 | 431 | } | ||
507 | 432 | ] | ||
509 | 433 | 422 | ||
510 | 434 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: | 423 | with self.assertRaises(snapcraft.yaml.SnapcraftSchemaError) as raised: |
511 | 435 | snapcraft.yaml._validate_snapcraft_yaml(self.data) | 424 | snapcraft.yaml._validate_snapcraft_yaml(self.data) |
512 | 436 | 425 | ||
514 | 437 | expected_message = '\'name\' is a required property' | 426 | expected_message = '\'start\' is a required property' |
515 | 438 | self.assertEqual(raised.exception.message, expected_message, msg=self.data) | 427 | self.assertEqual(raised.exception.message, expected_message, msg=self.data) |
516 | 439 | 428 | ||
517 | 440 | def test_schema_file_not_found(self): | 429 | def test_schema_file_not_found(self): |
Looks good.