Files
cibuildwheel/test/test_0_basic.py
T

80 lines
2.2 KiB
Python
Raw Normal View History

from __future__ import annotations
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
2021-06-23 10:47:18 -04:00
def test(tmp_path, build_frontend_env):
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
basic_project.generate(project_dir)
# build the wheels
2021-06-23 10:47:18 -04:00
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=build_frontend_env)
# 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
expected_wheels = utils.expected_wheels("spam", "0.1.0")
build_identifiers = utils.cibuildwheel_get_build_identifiers(
project_dir, prerelease_pythons=True
)
assert len(expected_wheels) == len(
build_identifiers
), f"{expected_wheels} vs {build_identifiers}"
def test_allow_empty(tmp_path):
project_dir = tmp_path / "project"
basic_project.generate(project_dir)
# Sanity check - --allow-empty should cause a no-op build to complete
# without error
actual_wheels = utils.cibuildwheel_run(
project_dir,
add_env={"CIBW_BUILD": "BUILD_NOTHING_AT_ALL"},
add_args=["--allow-empty"],
)
2022-04-13 10:19:43 +01:00
# check that nothing was built
assert len(actual_wheels) == 0