Skip to content

Commit 07e1847

Browse files
committed
[test] Add test for jpeg and clean code
We can remove the `get_recipe_env` because the environment that we use is already using a clang as default compiler (not the case when we migrated the jpeg recipe to use `cmake`)...so we can do a little refactor :)
1 parent 19da3c2 commit 07e1847

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

pythonforandroid/recipes/jpeg/__init__.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pythonforandroid.logger import shprint
33
from pythonforandroid.util import current_directory
44
from os.path import join
5-
from os import environ, uname
65
import sh
76

87

@@ -35,10 +34,9 @@ def build_arch(self, arch):
3534
'-DCMAKE_POSITION_INDEPENDENT_CODE=1',
3635
'-DCMAKE_ANDROID_ARCH_ABI={arch}'.format(arch=arch.arch),
3736
'-DCMAKE_ANDROID_NDK=' + self.ctx.ndk_dir,
38-
'-DCMAKE_C_COMPILER={toolchain}/bin/clang'.format(
39-
toolchain=env['TOOLCHAIN']),
40-
'-DCMAKE_CXX_COMPILER={toolchain}/bin/clang++'.format(
41-
toolchain=env['TOOLCHAIN']),
37+
'-DCMAKE_C_COMPILER={cc}'.format(cc=arch.get_clang_exe()),
38+
'-DCMAKE_CXX_COMPILER={cc_plus}'.format(
39+
cc_plus=arch.get_clang_exe(plus_plus=True)),
4240
'-DCMAKE_BUILD_TYPE=Release',
4341
'-DCMAKE_INSTALL_PREFIX=./install',
4442
'-DCMAKE_TOOLCHAIN_FILE=' + toolchain_file,
@@ -54,16 +52,5 @@ def build_arch(self, arch):
5452
_env=env)
5553
shprint(sh.make, _env=env)
5654

57-
def get_recipe_env(self, arch=None, with_flags_in_cc=False):
58-
env = environ.copy()
59-
60-
build_platform = '{system}-{machine}'.format(
61-
system=uname()[0], machine=uname()[-1]).lower()
62-
env['TOOLCHAIN'] = join(self.ctx.ndk_dir, 'toolchains/llvm/'
63-
'prebuilt/{build_platform}'.format(
64-
build_platform=build_platform))
65-
66-
return env
67-
6855

6956
recipe = JpegRecipe()

tests/recipes/test_jpeg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import unittest
2+
from tests.recipes.recipe_lib_test import BaseTestForCmakeRecipe
3+
4+
5+
class TestJpegRecipe(BaseTestForCmakeRecipe, unittest.TestCase):
6+
"""
7+
An unittest for recipe :mod:`~pythonforandroid.recipes.jpeg`
8+
"""
9+
recipe_name = "jpeg"

0 commit comments

Comments
 (0)