Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test_builds/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

py.test -s
65 changes: 65 additions & 0 deletions test_builds/tests/test_apk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

from pythonforandroid.toolchain import main

from os import path
import sys

import pytest

# Set these values manually before testing (for now)
ndk_dir = '/home/asandy/android/crystax-ndk-10.3.2'
ndk_version='crystax-ndk-10.3.2'

cur_dir = path.dirname(path.abspath(__file__))
testapps_dir = path.join(path.split(path.split(cur_dir)[0])[0], 'testapps')

orig_argv = sys.argv[:]

def set_argv(argv):
while sys.argv:
sys.argv.pop()
sys.argv.append(orig_argv[0])
for item in argv:
sys.argv.append(item)
for item in orig_argv[1:]:
if item == '-s':
continue
sys.argv.append(item)


argument_combinations = [{'app_dir': path.join(testapps_dir, 'testapp'),
'requirements': 'python2,pyjnius,kivy',
'packagename': 'p4a_test_sdl2',
'bootstrap': 'sdl2',
'ndk_dir': ndk_dir,
'ndk_version': ndk_version},
{'app_dir': path.join(testapps_dir, 'testapp'),
'requirements': 'python2,pyjnius,kivy',
'packagename': 'p4a_test_pygame',
'bootstrap': 'pygame',
'ndk_dir': ndk_dir,
'ndk_version': ndk_version},
{'app_dir': path.join(testapps_dir, 'testapp_flask'),
'requirements': 'python2,flask,pyjnius',
'packagename': 'p4a_test_flask',
'bootstrap': 'webview',
'ndk_dir': ndk_dir,
'ndk_version': ndk_version},
]


@pytest.mark.parametrize('args', argument_combinations)
def test_build_sdl2(args):

set_argv(('apk --requirements={requirements} --private '
'{app_dir} --package=net.p4a.{packagename} --name={packagename} '
'--version=0.1 --bootstrap={bootstrap} --android_api=19 '
'--ndk_dir={ndk_dir} --ndk_version={ndk_version} --debug '
'--permission VIBRATE '
'--orientation portrait --dist_name=test-{packagename}').format(
**args).split(' '))

print('argv are', sys.argv)

main()

13 changes: 12 additions & 1 deletion tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,33 @@
[(['python3crystax'], Bootstrap.get_bootstrap('sdl2', ctx)),
(['kivy', 'python3crystax'], Bootstrap.get_bootstrap('sdl2', ctx))])


@pytest.mark.parametrize('names,bootstrap', valid_combinations)
def test_valid_recipe_order_and_bootstrap(names, bootstrap):
get_recipe_order_and_bootstrap(ctx, names, bootstrap)

invalid_combinations = [[['python2', 'python3crystax'], None],
[['python3'], Bootstrap.get_bootstrap('pygame', ctx)]]


@pytest.mark.parametrize('names,bootstrap', invalid_combinations)
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
with pytest.raises(SystemExit):
get_recipe_order_and_bootstrap(ctx, names, bootstrap)


def test_bootstrap_dependency_addition():
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
ctx, ['kivy'], None)
assert (('hostpython2' in build_order) or ('hostpython3' in build_order))


def test_bootstrap_dependency_addition2():
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
ctx, ['kivy', 'python2'], None)
assert 'hostpython2' in build_order


if __name__ == "__main__":
get_recipe_order_and_bootstrap(ctx, ['python3'], Bootstrap.get_bootstrap('sdl2', ctx))
get_recipe_order_and_bootstrap(ctx, ['python3'],
Bootstrap.get_bootstrap('sdl2', ctx))