Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,15 @@ def build(options: Options, tmp_path: Path) -> None:

if build_options.test_sources:
test_cwd = identifier_tmp_dir / "test_cwd"
test_cwd.mkdir(exist_ok=True)
copy_test_sources(
build_options.test_sources,
build_options.package_dir,
test_cwd,
)
# only create test_cwd if it doesn't already exist - it
# may have been created during a previous `testing_arch`
if not test_cwd.exists():
test_cwd.mkdir()
copy_test_sources(
build_options.test_sources,
build_options.package_dir,
test_cwd,
)
else:
# There are no test sources. Run the tests in the project directory.
test_cwd = Path(".").resolve()
Expand Down
23 changes: 21 additions & 2 deletions test/test_macos_archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from . import test_projects, utils

basic_project = test_projects.new_c_project()
basic_project.files["tests/test_suite.py"] = r"""
import platform
print("running tests on " + platform.machine())
"""


ALL_MACOS_WHEELS = {
*utils.expected_wheels("spam", "0.1.0", machine_arch="x86_64"),
Expand Down Expand Up @@ -51,7 +56,21 @@ def test_cross_compiled_build(tmp_path):


@pytest.mark.parametrize("build_universal2", [False, True])
def test_cross_compiled_test(tmp_path, capfd, build_universal2):
@pytest.mark.parametrize(
"test_config",
[
# Run the test suite in the project folder
{
"CIBW_TEST_COMMAND": '''python -c "import platform; print('running tests on ' + platform.machine())"''',
},
# Nominate the set of test sources to copy
{
"CIBW_TEST_COMMAND": "python tests/test_suite.py",
"CIBW_TEST_SOURCES": "tests",
},
],
)
def test_cross_compiled_test(tmp_path, capfd, build_universal2, test_config):
if utils.platform != "macos":
pytest.skip("this test is only relevant to macos")
if get_xcode_version() < (12, 2):
Expand All @@ -64,9 +83,9 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
project_dir,
add_env={
"CIBW_BUILD": "cp310-*" if build_universal2 else "*p310-*",
"CIBW_TEST_COMMAND": '''python -c "import platform; print('running tests on ' + platform.machine())"''',
"CIBW_ARCHS": "universal2" if build_universal2 else "x86_64 arm64",
"CIBW_BUILD_VERBOSITY": "3",
**test_config,
},
)

Expand Down
Loading