Files
cibuildwheel/test/test_0_basic.py
T

69 lines
2.0 KiB
Python
Raw Normal View History

2020-05-02 22:50:52 +01:00
import platform
2020-11-14 14:50:29 +00:00
import textwrap
2021-01-06 13:50:58 -05:00
2020-11-14 14:50:29 +00:00
import pytest
from cibuildwheel.logger import Logger
2021-01-06 13:50:58 -05:00
2020-11-14 14:50:29 +00:00
from . import test_projects, utils
2020-05-02 16:54:19 +01:00
basic_project = test_projects.new_c_project(
2021-04-30 17:56:34 -04:00
setup_py_add=textwrap.dedent(
2021-05-03 11:45:43 -04:00
"""
2020-05-02 16:54:19 +01:00
import os
if os.environ.get("CIBUILDWHEEL", "0") != "1":
raise Exception("CIBUILDWHEEL environment variable is not set to 1")
2021-05-03 11:45:43 -04:00
"""
2021-04-30 17:56:34 -04:00
)
2020-05-02 16:54:19 +01:00
)
2020-05-02 22:50:52 +01:00
def test(tmp_path):
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
basic_project.generate(project_dir)
# build the wheels
actual_wheels = utils.cibuildwheel_run(project_dir)
# check that the expected wheels are produced
2021-05-03 11:45:43 -04:00
expected_wheels = utils.expected_wheels("spam", "0.1.0")
assert set(actual_wheels) == set(expected_wheels)
2021-05-03 11:45:43 -04:00
@pytest.mark.skip(reason="to keep test output clean")
def test_sample_build(tmp_path, capfd):
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
2020-05-02 16:54:19 +01:00
basic_project.generate(project_dir)
2020-11-05 23:09:28 +00:00
# build the wheels, and let the output passthrough to the caller, so
# we can see how it looks
with capfd.disabled():
logger = Logger()
2021-05-03 11:45:43 -04:00
logger.step("test_sample_build")
try:
utils.cibuildwheel_run(project_dir)
finally:
logger.step_end()
2020-05-02 16:54:19 +01:00
2020-05-03 14:08:57 +01:00
def test_build_identifiers(tmp_path):
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
2020-05-02 16:54:19 +01:00
basic_project.generate(project_dir)
# check that the number of expected wheels matches the number of build
# identifiers
# after adding CIBW_MANYLINUX_IMAGE to support manylinux2010, there
# can be multiple wheels for each wheel, though, so we need to limit
# the expected wheels
2021-05-03 11:45:43 -04:00
if platform.machine() in ["x86_64", "i686"]:
2021-04-30 17:56:34 -04:00
expected_wheels = [
w
2021-05-03 11:45:43 -04:00
for w in utils.expected_wheels("spam", "0.1.0")
if "-manylinux" not in w or "-manylinux1" in w
2021-04-30 17:56:34 -04:00
]
2020-05-02 22:50:52 +01:00
else:
2021-05-03 11:45:43 -04:00
expected_wheels = utils.expected_wheels("spam", "0.1.0")
2020-05-02 16:54:19 +01:00
build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
assert len(expected_wheels) == len(build_identifiers)