From 5fdbbcbe3ad46c787f95caa234d7382c4d08167b Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 14 May 2023 20:52:50 +0100 Subject: [PATCH] add unit test for create_args --- ...est_podman.py => test_container_engine.py} | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) rename test/{test_podman.py => test_container_engine.py} (57%) diff --git a/test/test_podman.py b/test/test_container_engine.py similarity index 57% rename from test/test_podman.py rename to test/test_container_engine.py index ea3bd8a6..10c09b0d 100644 --- a/test/test_podman.py +++ b/test/test_container_engine.py @@ -7,7 +7,7 @@ from . import test_projects, utils basic_project = test_projects.new_c_project() -def test(tmp_path, capfd, request): +def test_podman(tmp_path, capfd, request): if utils.platform != "linux": pytest.skip("the test is only relevant to the linux build") @@ -38,3 +38,29 @@ def test(tmp_path, capfd, request): # check that stdout is bring passed-though from container correctly captured = capfd.readouterr() assert "test log statement from before-all" in captured.out + + +def test_create_args(tmp_path, capfd): + if utils.platform != "linux": + 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={ + "CIBW_BUILD": "cp310-manylinux_*", + "CIBW_BEFORE_ALL": "echo TEST_CREATE_ARGS is set to $TEST_CREATE_ARGS", + "CIBW_CONTAINER_ENGINE": "docker; create_args: --env=TEST_CREATE_ARGS=itworks", + }, + ) + + expected_wheels = [ + w for w in utils.expected_wheels("spam", "0.1.0") if ("cp310-manylinux" in w) + ] + assert set(actual_wheels) == set(expected_wheels) + + captured = capfd.readouterr() + assert "TEST_CREATE_ARGS is set to itworks" in captured.out