Skip to content

Commit a0bacf5

Browse files
committedOct 2, 2016
Added apk building tests
1 parent c36cf0d commit a0bacf5

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
 

‎test_builds/test.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
py.test -s

‎test_builds/tests/test_apk.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
from pythonforandroid.toolchain import main
3+
4+
from os import path
5+
import sys
6+
7+
import pytest
8+
9+
# Set these values manually before testing (for now)
10+
ndk_dir = '/home/asandy/android/crystax-ndk-10.3.2'
11+
ndk_version='crystax-ndk-10.3.2'
12+
13+
cur_dir = path.dirname(path.abspath(__file__))
14+
testapps_dir = path.join(path.split(path.split(cur_dir)[0])[0], 'testapps')
15+
16+
orig_argv = sys.argv[:]
17+
18+
def set_argv(argv):
19+
while sys.argv:
20+
sys.argv.pop()
21+
sys.argv.append(orig_argv[0])
22+
for item in argv:
23+
sys.argv.append(item)
24+
for item in orig_argv[1:]:
25+
if item == '-s':
26+
continue
27+
sys.argv.append(item)
28+
29+
30+
argument_combinations = [{'app_dir': path.join(testapps_dir, 'testapp'),
31+
'requirements': 'python2,pyjnius,kivy',
32+
'packagename': 'p4a_test_sdl2',
33+
'bootstrap': 'sdl2',
34+
'ndk_dir': ndk_dir,
35+
'ndk_version': ndk_version},
36+
{'app_dir': path.join(testapps_dir, 'testapp'),
37+
'requirements': 'python2,pyjnius,kivy',
38+
'packagename': 'p4a_test_pygame',
39+
'bootstrap': 'pygame',
40+
'ndk_dir': ndk_dir,
41+
'ndk_version': ndk_version},
42+
{'app_dir': path.join(testapps_dir, 'testapp_flask'),
43+
'requirements': 'python2,flask',
44+
'packagename': 'p4a_test_flask',
45+
'bootstrap': 'webview',
46+
'ndk_dir': ndk_dir,
47+
'ndk_version': ndk_version},
48+
]
49+
50+
51+
@pytest.mark.parametrize('args', argument_combinations)
52+
def test_build_sdl2(args):
53+
54+
set_argv(('apk --requirements={requirements} --private '
55+
'{app_dir} --package=net.p4a.{packagename} --name={packagename} '
56+
'--version=0.1 --bootstrap={bootstrap} --android_api=19 '
57+
'--ndk_dir={ndk_dir} --ndk_version={ndk_version} --debug '
58+
'--orientation portrait --dist_name=test-{packagename}').format(
59+
**args).split(' '))
60+
61+
print('argv are', sys.argv)
62+
63+
main()
64+

0 commit comments

Comments
 (0)
Please sign in to comment.