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
|
|
|
|
2020-05-17 16:54:33 +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"
|
2020-11-14 14:28:47 +00:00
|
|
|
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)
|
2020-11-14 14:28:47 +00:00
|
|
|
|
|
|
|
|
# check that the expected wheels are produced
|
2021-05-03 11:45:43 -04:00
|
|
|
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
2020-11-14 14:28:47 +00:00
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|
|
|
|
|
|
|
|
|
|
|
2021-05-03 11:45:43 -04:00
|
|
|
@pytest.mark.skip(reason="to keep test output clean")
|
2020-11-14 14:28:47 +00:00
|
|
|
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():
|
2020-11-13 15:22:43 +00:00
|
|
|
logger = Logger()
|
2021-05-03 11:45:43 -04:00
|
|
|
logger.step("test_sample_build")
|
2020-11-14 14:28:47 +00:00
|
|
|
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
|
2021-04-03 16:59:10 +02:00
|
|
|
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
2021-05-29 00:26:55 +02:00
|
|
|
build_identifiers = utils.cibuildwheel_get_build_identifiers(
|
|
|
|
|
project_dir, prerelease_pythons=True
|
|
|
|
|
)
|
2021-09-20 08:12:35 +02:00
|
|
|
assert len(expected_wheels) == len(
|
|
|
|
|
build_identifiers
|
|
|
|
|
), f"{expected_wheels} vs {build_identifiers}"
|
2022-04-13 10:15:36 +01:00
|
|
|
|
|
|
|
|
|
2022-04-19 16:02:23 +01:00
|
|
|
def test_allow_empty(tmp_path):
|
2022-04-13 10:15:36 +01:00
|
|
|
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(
|
2022-04-14 10:21:21 +01:00
|
|
|
project_dir,
|
2022-04-19 16:02:23 +01:00
|
|
|
add_env={"CIBW_BUILD": "BUILD_NOTHING_AT_ALL"},
|
2022-04-14 09:22:13 +00:00
|
|
|
add_args=["--allow-empty"],
|
2022-04-13 09:16:22 +00:00
|
|
|
)
|
2022-04-13 10:15:36 +01:00
|
|
|
|
2022-04-13 10:19:43 +01:00
|
|
|
# check that nothing was built
|
|
|
|
|
assert len(actual_wheels) == 0
|