Add integration test for emulation
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_addoption(parser):
|
||||||
|
parser.addoption(
|
||||||
|
"--run-emulation", action="store_true", default=False, help="run emulation tests"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
config.addinivalue_line("markers", "emulation: mark test requiring qemu binfmt_misc to run")
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_collection_modifyitems(config, items):
|
||||||
|
if config.getoption("--run-emulation"):
|
||||||
|
# --run-emulation given in cli: do not skip emulation tests
|
||||||
|
return
|
||||||
|
skip_emulation = pytest.mark.skip(reason="need --run-emulation option to run")
|
||||||
|
for item in items:
|
||||||
|
if "emulation" in item.keywords:
|
||||||
|
item.add_marker(skip_emulation)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import pytest
|
||||||
|
from . import utils
|
||||||
|
from . import test_projects
|
||||||
|
|
||||||
|
|
||||||
|
project_with_a_test = test_projects.new_c_project()
|
||||||
|
|
||||||
|
project_with_a_test.files['test/spam_test.py'] = r'''
|
||||||
|
import spam
|
||||||
|
|
||||||
|
def test_spam():
|
||||||
|
assert spam.system('python -c "exit(0)"') == 0
|
||||||
|
assert spam.system('python -c "exit(1)"') != 0
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.emulation
|
||||||
|
def test(tmp_path):
|
||||||
|
project_dir = tmp_path / 'project'
|
||||||
|
project_with_a_test.generate(project_dir)
|
||||||
|
|
||||||
|
# build and test the wheels
|
||||||
|
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||||
|
'CIBW_TEST_REQUIRES': 'pytest',
|
||||||
|
'CIBW_TEST_COMMAND': 'pytest {project}/test',
|
||||||
|
'CIBW_ARCHS': 'aarch64 ppc64le s390x',
|
||||||
|
})
|
||||||
|
|
||||||
|
# also check that we got the right wheels
|
||||||
|
expected_wheels = (
|
||||||
|
utils.expected_wheels('spam', '0.1.0', machine_arch='aarch64')
|
||||||
|
+ utils.expected_wheels('spam', '0.1.0', machine_arch='ppc64le')
|
||||||
|
+ utils.expected_wheels('spam', '0.1.0', machine_arch='s390x')
|
||||||
|
)
|
||||||
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
+8
-5
@@ -76,7 +76,7 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp
|
|||||||
|
|
||||||
|
|
||||||
def expected_wheels(package_name, package_version, manylinux_versions=None,
|
def expected_wheels(package_name, package_version, manylinux_versions=None,
|
||||||
macosx_deployment_target='10.9'):
|
macosx_deployment_target='10.9', machine_arch=None):
|
||||||
'''
|
'''
|
||||||
Returns a list of expected wheels from a run of cibuildwheel.
|
Returns a list of expected wheels from a run of cibuildwheel.
|
||||||
'''
|
'''
|
||||||
@@ -85,15 +85,18 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
|
|||||||
# {python tag} and {abi tag} are closely related to the python interpreter used to build the wheel
|
# {python tag} and {abi tag} are closely related to the python interpreter used to build the wheel
|
||||||
# so we'll merge them below as python_abi_tag
|
# so we'll merge them below as python_abi_tag
|
||||||
|
|
||||||
|
if machine_arch is None:
|
||||||
|
machine_arch = pm.machine()
|
||||||
|
|
||||||
if manylinux_versions is None:
|
if manylinux_versions is None:
|
||||||
if pm.machine() == 'x86_64':
|
if machine_arch == 'x86_64':
|
||||||
manylinux_versions = ['manylinux1', 'manylinux2010']
|
manylinux_versions = ['manylinux1', 'manylinux2010']
|
||||||
else:
|
else:
|
||||||
manylinux_versions = ['manylinux2014']
|
manylinux_versions = ['manylinux2014']
|
||||||
|
|
||||||
python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39']
|
python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39']
|
||||||
|
|
||||||
if pm.machine() in ['x86_64', 'AMD64', 'x86']:
|
if machine_arch in ['x86_64', 'AMD64', 'x86']:
|
||||||
python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73', 'pp37-pypy37_pp73']
|
python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73', 'pp37-pypy37_pp73']
|
||||||
|
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
@@ -105,9 +108,9 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
|
|||||||
platform_tags = []
|
platform_tags = []
|
||||||
|
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
architectures = [pm.machine()]
|
architectures = [machine_arch]
|
||||||
|
|
||||||
if pm.machine() == 'x86_64' and python_abi_tag.startswith('cp'):
|
if machine_arch == 'x86_64' and python_abi_tag.startswith('cp'):
|
||||||
architectures.append('i686')
|
architectures.append('i686')
|
||||||
|
|
||||||
platform_tags = [
|
platform_tags = [
|
||||||
|
|||||||
Reference in New Issue
Block a user