|
4 | 4 | import platform |
5 | 5 | import shutil |
6 | 6 | import subprocess |
| 7 | +import textwrap |
7 | 8 |
|
8 | 9 | import pytest |
9 | 10 |
|
@@ -80,21 +81,10 @@ def test_ios_platforms(tmp_path, build_config, monkeypatch, capfd): |
80 | 81 | ) |
81 | 82 |
|
82 | 83 | # The expected wheels were produced. |
83 | | - ios_version = os.getenv("IPHONEOS_DEPLOYMENT_TARGET", "13.0").replace(".", "_") |
84 | | - platform_machine = platform.machine() |
85 | | - |
86 | | - if platform_machine == "x86_64": |
87 | | - expected_wheels = { |
88 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_x86_64_iphonesimulator.whl", |
89 | | - } |
90 | | - |
91 | | - elif platform_machine == "arm64": |
92 | | - expected_wheels = { |
93 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphoneos.whl", |
94 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphonesimulator.whl", |
95 | | - } |
96 | | - |
97 | | - assert set(actual_wheels) == expected_wheels |
| 84 | + expected_wheels = utils.expected_wheels( |
| 85 | + "spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] |
| 86 | + ) |
| 87 | + assert set(actual_wheels) == set(expected_wheels) |
98 | 88 |
|
99 | 89 | # The user was notified that the cross-build tool was found. |
100 | 90 | captured = capfd.readouterr() |
@@ -180,21 +170,10 @@ def test_no_xbuild_tool_definition(tmp_path, capfd): |
180 | 170 | ) |
181 | 171 |
|
182 | 172 | # The expected wheels were produced. |
183 | | - ios_version = os.getenv("IPHONEOS_DEPLOYMENT_TARGET", "13.0").replace(".", "_") |
184 | | - platform_machine = platform.machine() |
185 | | - |
186 | | - if platform_machine == "x86_64": |
187 | | - expected_wheels = { |
188 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_x86_64_iphonesimulator.whl", |
189 | | - } |
190 | | - |
191 | | - elif platform_machine == "arm64": |
192 | | - expected_wheels = { |
193 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphoneos.whl", |
194 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphonesimulator.whl", |
195 | | - } |
196 | | - |
197 | | - assert set(actual_wheels) == expected_wheels |
| 173 | + expected_wheels = utils.expected_wheels( |
| 174 | + "spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] |
| 175 | + ) |
| 176 | + assert set(actual_wheels) == set(expected_wheels) |
198 | 177 |
|
199 | 178 | # The user was notified that there was no cross-build tool definition. |
200 | 179 | captured = capfd.readouterr() |
@@ -225,23 +204,48 @@ def test_empty_xbuild_tool_definition(tmp_path, capfd): |
225 | 204 | }, |
226 | 205 | ) |
227 | 206 |
|
228 | | - # The expected wheels were produced. |
229 | | - ios_version = os.getenv("IPHONEOS_DEPLOYMENT_TARGET", "13.0").replace(".", "_") |
230 | | - platform_machine = platform.machine() |
231 | | - |
232 | | - if platform_machine == "x86_64": |
233 | | - expected_wheels = { |
234 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_x86_64_iphonesimulator.whl", |
235 | | - } |
236 | | - |
237 | | - elif platform_machine == "arm64": |
238 | | - expected_wheels = { |
239 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphoneos.whl", |
240 | | - f"spam-0.1.0-cp313-cp313-ios_{ios_version}_arm64_iphonesimulator.whl", |
241 | | - } |
242 | | - |
243 | | - assert set(actual_wheels) == expected_wheels |
| 207 | + expected_wheels = utils.expected_wheels( |
| 208 | + "spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] |
| 209 | + ) |
| 210 | + assert set(actual_wheels) == set(expected_wheels) |
244 | 211 |
|
245 | 212 | # The warnings about cross-build notifications were silenced. |
246 | 213 | captured = capfd.readouterr() |
247 | 214 | assert "Your project configuration does not define any cross-build tools." not in captured.err |
| 215 | + |
| 216 | + |
| 217 | +def test_ios_test_command_without_python_dash_m(tmp_path, capfd): |
| 218 | + """Test command should be able to run without python -m.""" |
| 219 | + if utils.platform != "macos": |
| 220 | + pytest.skip("this test can only run on macOS") |
| 221 | + if utils.get_xcode_version() < (13, 0): |
| 222 | + pytest.skip("this test only works with Xcode 13.0 or greater") |
| 223 | + |
| 224 | + project_dir = tmp_path / "project" |
| 225 | + project = test_projects.new_c_project() |
| 226 | + project.files["tests_module/__init__.py"] = "" |
| 227 | + project.files["tests_module/__main__.py"] = textwrap.dedent(""" |
| 228 | + if __name__ == "__main__": |
| 229 | + print("Hello from tests_module") |
| 230 | + """) |
| 231 | + project.generate(project_dir) |
| 232 | + |
| 233 | + actual_wheels = utils.cibuildwheel_run( |
| 234 | + project_dir, |
| 235 | + add_env={ |
| 236 | + "CIBW_PLATFORM": "ios", |
| 237 | + "CIBW_BUILD": "cp313-*", |
| 238 | + "CIBW_TEST_COMMAND": "tests_module", |
| 239 | + "CIBW_TEST_SOURCES": "tests_module", |
| 240 | + "CIBW_XBUILD_TOOLS": "", |
| 241 | + }, |
| 242 | + ) |
| 243 | + |
| 244 | + expected_wheels = utils.expected_wheels( |
| 245 | + "spam", "0.1.0", platform="ios", python_abi_tags=["cp313-cp313"] |
| 246 | + ) |
| 247 | + assert set(actual_wheels) == set(expected_wheels) |
| 248 | + |
| 249 | + out, err = capfd.readouterr() |
| 250 | + |
| 251 | + assert "iOS tests configured with a test command which doesn't start with 'python -m'" in err |
0 commit comments