From b1b6d6acb02c7e5821ee5fae6157b03a53bba4b4 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 15 Nov 2020 14:49:34 +0700 Subject: [PATCH] Support running tests on any arch --- tests/recipes/test_icu.py | 4 ++-- tests/test_archs.py | 5 ++--- tests/test_bootstrap.py | 5 ++--- tests/test_recipe.py | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/recipes/test_icu.py b/tests/recipes/test_icu.py index 00cfbdbbe7..39c29047f7 100644 --- a/tests/recipes/test_icu.py +++ b/tests/recipes/test_icu.py @@ -1,10 +1,10 @@ import os import unittest from unittest import mock -from platform import system from tests.recipes.recipe_ctx import RecipeCtx from pythonforandroid.recipes.icu import ICURecipe +from pythonforandroid.util import build_platform class TestIcuRecipe(RecipeCtx, unittest.TestCase): @@ -48,7 +48,7 @@ def test_build_arch( ): mock_find_executable.return_value = os.path.join( self.ctx._ndk_dir, - f"toolchains/llvm/prebuilt/{system().lower()}-x86_64/bin/clang", + f"toolchains/llvm/prebuilt/{build_platform}/bin/clang", ) mock_archs_glob.return_value = [ os.path.join(self.ctx._ndk_dir, "toolchains", "llvm") diff --git a/tests/test_archs.py b/tests/test_archs.py index 61887e0e51..3b6b86e218 100644 --- a/tests/test_archs.py +++ b/tests/test_archs.py @@ -2,13 +2,12 @@ import unittest from os import environ from unittest import mock -from platform import system from pythonforandroid.bootstrap import Bootstrap from pythonforandroid.distribution import Distribution from pythonforandroid.recipe import Recipe from pythonforandroid.build import Context -from pythonforandroid.util import BuildInterruptingException +from pythonforandroid.util import BuildInterruptingException, build_platform from pythonforandroid.archs import ( Arch, ArchARM, @@ -72,7 +71,7 @@ def setUp(self): # should be the same for all the tests (no more gcc compiler) self.expected_compiler = ( f"/opt/android/android-ndk/toolchains/" - f"llvm/prebuilt/{system().lower()}-x86_64/bin/clang" + f"llvm/prebuilt/{build_platform}/bin/clang" ) diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index f1cff91437..8fcedb53a7 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -4,7 +4,6 @@ import unittest from unittest import mock -from platform import system from pythonforandroid.bootstrap import ( _cmp_bootstraps_by_priority, Bootstrap, expand_dependencies, @@ -13,7 +12,7 @@ from pythonforandroid.recipe import Recipe from pythonforandroid.archs import ArchARMv7_a from pythonforandroid.build import Context -from pythonforandroid.util import BuildInterruptingException +from pythonforandroid.util import BuildInterruptingException, build_platform from test_graph import get_fake_recipe @@ -531,7 +530,7 @@ def test_bootstrap_strip( ): mock_find_executable.return_value = os.path.join( self.ctx._ndk_dir, - f"toolchains/llvm/prebuilt/{system().lower()}-x86_64/bin/clang", + f"toolchains/llvm/prebuilt/{build_platform}/bin/clang", ) mock_glob.return_value = [ os.path.join(self.ctx._ndk_dir, "toolchains", "llvm") diff --git a/tests/test_recipe.py b/tests/test_recipe.py index ef5e1ad412..ffe254cb58 100644 --- a/tests/test_recipe.py +++ b/tests/test_recipe.py @@ -5,12 +5,12 @@ import warnings from unittest import mock from backports import tempfile -from platform import system from pythonforandroid.build import Context from pythonforandroid.recipe import Recipe, import_recipe from pythonforandroid.archs import ArchAarch_64 from pythonforandroid.bootstrap import Bootstrap +from pythonforandroid.util import build_platform from test_bootstrap import BaseClassSetupBootstrap @@ -284,7 +284,7 @@ def test_get_recipe_env_with( """ expected_compiler = ( f"/opt/android/android-ndk/toolchains/" - f"llvm/prebuilt/{system().lower()}-x86_64/bin/clang" + f"llvm/prebuilt/{build_platform}/bin/clang" ) mock_find_executable.return_value = expected_compiler mock_glob.return_value = ["llvm"]