Skip to content

Commit 9bc3209

Browse files
committed
Fix placeholders error message, add test for it
1 parent 9a5a2c8 commit 9bc3209

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

cibuildwheel/platforms/ios.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ def build(options: Options, tmp_path: Path) -> None:
606606
):
607607
msg = unwrap_preserving_paragraphs(
608608
f"""
609-
iOS tests configured with a test command that uses the {{"project"}} or
610-
{{"package"}} placeholder. iOS tests cannot use placeholders, because the
609+
iOS tests configured with a test command that uses the "{{project}}" or
610+
"{{package}}" placeholder. iOS tests cannot use placeholders, because the
611611
source directory is not visible on the simulator.
612612
613613
In addition, iOS tests must run as a Python module, so the test command

test/test_ios.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_ios_platforms(tmp_path, build_config, monkeypatch, capfd):
9191
assert "'does-exist' will be included in the cross-build environment" in captured.out
9292

9393

94+
@pytest.mark.serial
9495
def test_no_test_sources(tmp_path, capfd):
9596
"""Build will provide a helpful error if pytest is run and test-sources is not defined."""
9697
if utils.get_platform() != "macos":
@@ -123,6 +124,35 @@ def test_no_test_sources(tmp_path, capfd):
123124
)
124125

125126

127+
def test_ios_testing_with_placeholder(tmp_path, capfd):
128+
"""Build will run tests with the {project} placeholder."""
129+
if utils.get_platform() != "macos":
130+
pytest.skip("this test can only run on macOS")
131+
if utils.get_xcode_version() < (13, 0):
132+
pytest.skip("this test only works with Xcode 13.0 or greater")
133+
134+
project_dir = tmp_path / "project"
135+
basic_project = test_projects.new_c_project()
136+
basic_project.files.update(basic_project_files)
137+
basic_project.generate(project_dir)
138+
139+
with pytest.raises(subprocess.CalledProcessError):
140+
utils.cibuildwheel_run(
141+
project_dir,
142+
add_env={
143+
"CIBW_PLATFORM": "ios",
144+
"CIBW_BUILD": "cp313-*",
145+
"CIBW_TEST_REQUIRES": "pytest",
146+
"CIBW_TEST_COMMAND": "pytest {project}/tests",
147+
"CIBW_XBUILD_TOOLS": "",
148+
},
149+
)
150+
151+
# The error message indicates the configuration issue.
152+
captured = capfd.readouterr()
153+
assert "iOS tests cannot use placeholders" in captured.out + captured.err
154+
155+
126156
def test_missing_xbuild_tool(tmp_path, capfd):
127157
"""Build will fail if xbuild-tools references a non-existent tool."""
128158
if utils.get_platform() != "macos":

0 commit comments

Comments
 (0)