Merge lp:~sergiusens/snapcraft/pypy-config-test into lp:~ted/snapcraft/python-pip

Proposed by Sergio Schvezov on 2015-09-17
Status: Superseded
Proposed branch: lp:~sergiusens/snapcraft/pypy-config-test
Merge into: lp:~ted/snapcraft/python-pip
Diff against target: 317 lines (+163/-50)
10 files modified
bin/snapcraft (+0/-1)
debian/control (+5/-14)
debian/rules (+0/-6)
debian/tests/control (+10/-0)
integration-tests/data/pypy-config/config.py (+57/-0)
integration-tests/data/pypy-config/setup.py (+16/-0)
integration-tests/data/pypy-config/snapcraft.yaml (+12/-0)
integration-tests/runtests.sh (+48/-0)
integration-tests/units/jobs.pxu (+13/-0)
runtests.sh (+2/-29)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/pypy-config-test
Reviewer Review Type Date Requested Status
Ted Gould 2015-09-17 Pending
Review via email: mp+271528@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-17.

Commit Message

setup.py using pypy to setup a config integration test

To post a comment you must log in.
176. By Sergio Schvezov on 2015-09-17

s/pypy/pypi/ and description and summary updated

177. By Sergio Schvezov on 2015-09-17

check hook

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/snapcraft'
2--- bin/snapcraft 2015-07-15 09:04:52 +0000
3+++ bin/snapcraft 2015-09-17 19:10:29 +0000
4@@ -31,4 +31,3 @@
5 if __name__ == "__main__":
6 snapcraft.dirs.setup_dirs()
7 snapcraft.main.main()
8-
9
10=== modified file 'debian/control'
11--- debian/control 2015-09-16 11:47:20 +0000
12+++ debian/control 2015-09-17 19:10:29 +0000
13@@ -6,43 +6,34 @@
14 cmake,
15 debhelper (>= 9),
16 dh-python,
17- git,
18- mercurial,
19- pep8,
20- plainbox,
21- pyflakes,
22 python3 (>= 3.4),
23 python3-apt,
24- python3-fixtures,
25 python3-jsonschema,
26- python3-mccabe,
27- python3-requests,
28 python3-setuptools,
29- python3-testscenarios,
30 python3-yaml,
31 ubuntu-snappy-cli,
32 wget,
33- xz-utils,
34+ xz-utils
35 Homepage: https://launchpad.net/snapcraft
36 Vcs-Bzr: lp:snapcraft
37 Standards-Version: 3.9.6
38
39 Package: snapcraft
40 Architecture: all
41-Depends: ${misc:Depends},
42- ${python3:Depends},
43- bzr,
44+Depends: bzr,
45 dpkg-dev,
46 git,
47+ mercurial,
48 python3-apt,
49 python3-jsonschema,
50 python3-requests,
51 python3-yaml,
52- mercurial,
53 sudo,
54 ubuntu-snappy-cli,
55 wget,
56 xz-utils,
57+ ${misc:Depends},
58+ ${python3:Depends}
59 Description: easily craft snaps
60 Snapcraft aims to make upstream developers' lives easier and as such is not
61 a single toolset, but instead is a collection of tools that enable the
62
63=== modified file 'debian/rules'
64--- debian/rules 2015-08-25 20:40:26 +0000
65+++ debian/rules 2015-09-17 19:10:29 +0000
66@@ -3,9 +3,3 @@
67
68 %:
69 dh $@ --with python3 --buildsystem=pybuild
70-
71-override_dh_auto_test:
72-ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
73- python3 setup.py test
74-endif
75-
76
77=== added directory 'debian/tests'
78=== added file 'debian/tests/control'
79--- debian/tests/control 1970-01-01 00:00:00 +0000
80+++ debian/tests/control 2015-09-17 19:10:29 +0000
81@@ -0,0 +1,10 @@
82+Test-Command: ./runtests.sh
83+Restrictions: allow-stderr, isolation-container
84+Depends: @,
85+ build-essential,
86+ pep8,
87+ plainbox,
88+ pyflakes,
89+ python3-fixtures,
90+ python3-mccabe,
91+ python3-testscenarios
92
93=== added directory 'integration-tests/data/pypy-config'
94=== added file 'integration-tests/data/pypy-config/config.py'
95--- integration-tests/data/pypy-config/config.py 1970-01-01 00:00:00 +0000
96+++ integration-tests/data/pypy-config/config.py 2015-09-17 19:10:29 +0000
97@@ -0,0 +1,57 @@
98+#!/usr/bin/env python3
99+
100+import os
101+import os.path
102+import sys
103+import yaml
104+
105+_CONFIG = 'configuration'
106+
107+_DEFAULT_INTERVAL = 10
108+
109+
110+def main():
111+ config_file = os.path.join(os.environ['SNAP_APP_DATA_PATH'], _CONFIG)
112+
113+ config_yaml = yaml.load(sys.stdin)
114+ if config_yaml:
115+ set_config(config_file, config_yaml)
116+
117+ yaml.dump(get_config(config_file), stream=sys.stdout, default_flow_style=False)
118+
119+
120+def set_config(config_file, config_yaml={}):
121+ with open(config_file, 'w') as f:
122+ yaml.dump(_config(config_yaml), stream=f, default_flow_style=False)
123+
124+ return config_yaml
125+
126+
127+def get_config(config_file):
128+ try:
129+ with open(config_file) as f:
130+ return yaml.load(f)
131+ except FileNotFoundError:
132+ return _config()
133+
134+
135+def _config(config_yaml={}):
136+ try:
137+ interval_value = config_yaml['config'][os.environ['SNAP_NAME']]['interval']
138+ if not isinstance(interval_value, int):
139+ config_yaml['config'][os.environ['SNAP_NAME']]['interval'] = _DEFAULT_INTERVAL
140+ except KeyError:
141+ interval = {
142+ 'config': {
143+ os.environ['SNAP_NAME']: {
144+ 'interval': _DEFAULT_INTERVAL
145+ }
146+ }
147+ }
148+ config_yaml.update(interval)
149+
150+ return config_yaml
151+
152+
153+if __name__ == '__main__':
154+ main()
155
156=== added file 'integration-tests/data/pypy-config/icon.png'
157Binary files integration-tests/data/pypy-config/icon.png 1970-01-01 00:00:00 +0000 and integration-tests/data/pypy-config/icon.png 2015-09-17 19:10:29 +0000 differ
158=== added file 'integration-tests/data/pypy-config/setup.py'
159--- integration-tests/data/pypy-config/setup.py 1970-01-01 00:00:00 +0000
160+++ integration-tests/data/pypy-config/setup.py 2015-09-17 19:10:29 +0000
161@@ -0,0 +1,16 @@
162+#!/usr/bin/env python3
163+
164+from setuptools import setup
165+
166+setup(
167+ name='config',
168+ description='config for webcam-webui',
169+ author='Sergio Schvezov <sergio.schvezov@canonical.com>',
170+ license='GPLv3',
171+ install_requires=[
172+ 'pyyaml',
173+ ],
174+ scripts=[
175+ 'config.py',
176+ ],
177+)
178
179=== added file 'integration-tests/data/pypy-config/snapcraft.yaml'
180--- integration-tests/data/pypy-config/snapcraft.yaml 1970-01-01 00:00:00 +0000
181+++ integration-tests/data/pypy-config/snapcraft.yaml 2015-09-17 19:10:29 +0000
182@@ -0,0 +1,12 @@
183+name: pypy-config
184+version: 1
185+vendor: Vendor <email@example.com>
186+summary: test summary
187+description: test desc
188+icon: icon.png
189+config: python3 usr/bin/config.py
190+
191+parts:
192+ config:
193+ type: python3-project
194+ source: .
195
196=== added file 'integration-tests/runtests.sh'
197--- integration-tests/runtests.sh 1970-01-01 00:00:00 +0000
198+++ integration-tests/runtests.sh 2015-09-17 19:10:29 +0000
199@@ -0,0 +1,48 @@
200+#!/bin/bash
201+# -*- Mode:sh; indent-tabs-mode:nil; tab-width:4 -*-
202+#
203+# Copyright (C) 2015 Canonical Ltd
204+#
205+# This program is free software: you can redistribute it and/or modify
206+# it under the terms of the GNU General Public License version 3 as
207+# published by the Free Software Foundation.
208+#
209+# This program is distributed in the hope that it will be useful,
210+# but WITHOUT ANY WARRANTY; without even the implied warranty of
211+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212+# GNU General Public License for more details.
213+#
214+# You should have received a copy of the GNU General Public License
215+# along with this program. If not, see <http://www.gnu.org/licenses/>.
216+
217+set -e
218+
219+if [ -z "$SNAPCRAFT" ]; then
220+ export SNAPCRAFT=snapcraft
221+fi
222+
223+# Create a temporary directory so that we can run 'manage.py develop' and
224+# create the .provider file there
225+temp_dir=$(mktemp -d)
226+# Develop the provider, this will let us run tests on it
227+./manage.py develop -d $temp_dir
228+# Set PROVIDERPATH (see plainbox(1)) so that we can see the provider
229+# without installing it.
230+export PROVIDERPATH=$PROVIDERPATH:$temp_dir
231+# Run the 'normal' test plan
232+plainbox run \
233+ -T 2015.com.canonical.snapcraft::normal \
234+ -f json -o $temp_dir/result.json
235+# Analyze the result and fail if there are any failures
236+python3 - << __PYTHON__
237+import json
238+with open("$temp_dir/result.json", "rt", encoding="utf-8") as stream:
239+ results = json.load(stream)
240+failed = False
241+for test_id, result in sorted(results['result_map'].items()):
242+ print('{0}: {1}'.format(test_id, result['outcome']))
243+ if result['outcome'] != 'pass':
244+ failed = True
245+print("Overall: {0}".format("fail" if failed else "pass"))
246+raise SystemExit(failed)
247+__PYTHON__
248
249=== modified file 'integration-tests/units/jobs.pxu'
250--- integration-tests/units/jobs.pxu 2015-09-17 15:14:49 +0000
251+++ integration-tests/units/jobs.pxu 2015-09-17 19:10:29 +0000
252@@ -81,6 +81,19 @@
253 test -e stage/slash
254 test "$(./stage/bin/test)" = "tarproject"
255
256+id: snapcraft/normal/pypy-config
257+plugin: shell
258+estimated_duration: 0.3
259+command:
260+ set -ex
261+ cp -rT $PLAINBOX_PROVIDER_DATA/pypy-config .
262+ ${SNAPCRAFT} snap
263+ test -f ./stage/usr/bin/config.py
264+ test -f ./stage/usr/bin/python3
265+ test -f ./snap/usr/bin/config.py
266+ test -f ./snap/usr/bin/python3
267+ test -f ./snap/meta/hooks/config
268+
269 id: snapcraft/normal/simple-make
270 plugin: shell
271 estimated_duration: 0.3
272
273=== modified file 'runtests.sh'
274--- runtests.sh 2015-09-15 14:45:57 +0000
275+++ runtests.sh 2015-09-17 19:10:29 +0000
276@@ -69,39 +69,12 @@
277 python3-coverage erase
278 export PROJECT_PATH=$(pwd)
279 export SNAPCRAFT=snapcraft-coverage
280- else
281- export SNAPCRAFT=snapcraft
282 fi
283
284 # Go to the plainbox provider of snapcraft tests
285- cd integration-tests/
286- # Create a temporary directory so that we can run 'manage.py develop' and
287- # create the .provider file there
288- temp_dir=$(mktemp -d)
289- # Develop the provider, this will let us run tests on it
290- ./manage.py develop -d $temp_dir
291- # Set PROVIDERPATH (see plainbox(1)) so that we can see the provider
292- # without installing it.
293- export PROVIDERPATH=$PROVIDERPATH:$temp_dir
294- # Run the 'normal' test plan
295- plainbox run \
296- -T 2015.com.canonical.snapcraft::normal \
297- -f json -o $temp_dir/result.json
298- # Analyze the result and fail if there are any failures
299- python3 - << __PYTHON__
300-import json
301-with open("$temp_dir/result.json", "rt", encoding="utf-8") as stream:
302- results = json.load(stream)
303-failed = False
304-for test_id, result in sorted(results['result_map'].items()):
305- print('{0}: {1}'.format(test_id, result['outcome']))
306- if result['outcome'] != 'pass':
307- failed = True
308-print("Overall: {0}".format("fail" if failed else "pass"))
309-raise SystemExit(failed)
310-__PYTHON__
311+ cd integration-tests
312+ ./runtests.sh
313 )
314-
315 fi
316
317 if which python3-coverage >/dev/null 2>&1; then

Subscribers

People subscribed via source and target branches

to all changes: