2022-06-27 19:08:46 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from . import test_projects, utils
|
|
|
|
|
|
|
|
|
|
basic_project = test_projects.new_c_project()
|
|
|
|
|
|
|
|
|
|
|
2023-05-14 20:52:50 +01:00
|
|
|
def test_podman(tmp_path, capfd, request):
|
2025-05-16 11:11:16 +01:00
|
|
|
if utils.get_platform() != "linux":
|
2022-06-27 19:08:46 +01:00
|
|
|
pytest.skip("the test is only relevant to the linux build")
|
|
|
|
|
|
|
|
|
|
if not request.config.getoption("--run-podman"):
|
|
|
|
|
pytest.skip("needs --run-podman option to run")
|
|
|
|
|
|
|
|
|
|
project_dir = tmp_path / "project"
|
|
|
|
|
basic_project.generate(project_dir)
|
|
|
|
|
|
|
|
|
|
# build some musllinux and manylinux wheels (ensuring that we use two containers)
|
|
|
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
|
|
|
project_dir,
|
|
|
|
|
add_env={
|
2024-09-12 21:32:43 +02:00
|
|
|
"CIBW_ARCHS": "native",
|
2022-06-27 19:08:46 +01:00
|
|
|
"CIBW_BEFORE_ALL": "echo 'test log statement from before-all'",
|
2022-06-27 19:19:00 +01:00
|
|
|
"CIBW_CONTAINER_ENGINE": "podman",
|
2022-06-27 19:08:46 +01:00
|
|
|
},
|
2024-05-26 12:41:20 +02:00
|
|
|
single_python=True,
|
2022-06-27 19:08:46 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# check that the expected wheels are produced
|
2024-09-12 21:32:43 +02:00
|
|
|
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True, single_arch=True)
|
2022-06-27 19:08:46 +01:00
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|
|
|
|
|
|
|
|
|
|
# check that stdout is bring passed-though from container correctly
|
|
|
|
|
captured = capfd.readouterr()
|
|
|
|
|
assert "test log statement from before-all" in captured.out
|
2023-05-14 20:52:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_args(tmp_path, capfd):
|
2025-05-16 11:11:16 +01:00
|
|
|
if utils.get_platform() != "linux":
|
2023-05-14 20:52:50 +01:00
|
|
|
pytest.skip("the test is only relevant to the linux build")
|
|
|
|
|
|
|
|
|
|
project_dir = tmp_path / "project"
|
|
|
|
|
basic_project.generate(project_dir)
|
|
|
|
|
|
|
|
|
|
# build a manylinux wheel, using create_args to set an environment variable
|
|
|
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
|
|
|
project_dir,
|
|
|
|
|
add_env={
|
2024-05-26 12:41:20 +02:00
|
|
|
"CIBW_SKIP": "*-musllinux_*",
|
2023-05-14 20:52:50 +01:00
|
|
|
"CIBW_BEFORE_ALL": "echo TEST_CREATE_ARGS is set to $TEST_CREATE_ARGS",
|
|
|
|
|
"CIBW_CONTAINER_ENGINE": "docker; create_args: --env=TEST_CREATE_ARGS=itworks",
|
|
|
|
|
},
|
2024-05-26 12:41:20 +02:00
|
|
|
single_python=True,
|
2023-05-14 20:52:50 +01:00
|
|
|
)
|
|
|
|
|
|
2024-05-26 12:41:20 +02:00
|
|
|
expected_wheels = utils.expected_wheels(
|
|
|
|
|
"spam", "0.1.0", musllinux_versions=[], single_python=True
|
|
|
|
|
)
|
2023-05-14 20:52:50 +01:00
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|
|
|
|
|
|
|
|
|
|
captured = capfd.readouterr()
|
|
|
|
|
assert "TEST_CREATE_ARGS is set to itworks" in captured.out
|