fix: change to the iOS testing option semantics (#2363)

* Change to the iOS testing option semantics

Don't assume the presence of `python -m` in the test command. Less magic
and allows more option reuse between platforms.

* Update schema

* Add a test for this warning

* Don't try to execute a test-command when it doesn't look like a module

* Update docs/options.md

Co-authored-by: Malcolm Smith <smith@chaquo.com>

* Only allow invalid test command if the first part is 'pytest'

* Responses to code review from @freakboy3742

* Fixes post-merge

---------

Co-authored-by: Malcolm Smith <smith@chaquo.com>
This commit is contained in:
Joe Rickerby
2025-05-18 22:42:23 -04:00
committed by GitHub
co-authored by Malcolm Smith
parent 1bc7e904b8
commit 898f0a45c1
5 changed files with 195 additions and 68 deletions
+10 -1
View File
@@ -1253,7 +1253,7 @@ run your test suite.
On all platforms other than iOS, the command is run in a shell, so you can write things like `cmd1 && cmd2`.
On iOS, the value of the `CIBW_TEST_COMMAND` setting is interpreted as the arguments to pass to `python -m` - that is, a Python module name, followed by arguments that will be assigned to `sys.argv`. Shell commands cannot be used.
On iOS, the value of the `CIBW_TEST_COMMAND` setting must follow the format `python -m MODULE [ARGS...]` - where MODULE is a Python module name, followed by arguments that will be assigned to `sys.argv`. Other commands cannot be used.
Platform-specific environment variables are also available:<br/>
`CIBW_TEST_COMMAND_MACOS` | `CIBW_TEST_COMMAND_WINDOWS` | `CIBW_TEST_COMMAND_LINUX` | `CIBW_TEST_COMMAND_IOS` | `CIBW_TEST_COMMAND_PYODIDE`
@@ -1273,6 +1273,10 @@ Platform-specific environment variables are also available:<br/>
CIBW_TEST_COMMAND: >
pytest ./tests &&
python ./test.py
# run tests on ios
CIBW_TEST_SOURCES_IOS: tests
CIBW_TEST_COMMAND_IOS: python -m pytest ./tests
```
!!! tab examples "pyproject.toml"
@@ -1290,6 +1294,11 @@ Platform-specific environment variables are also available:<br/>
"pytest ./tests",
"python ./test.py",
]
# run tests on ios
[tool.cibuildwheel.ios]
test-sources = ["tests"]
test-command = "python -m pytest ./tests"
```
In configuration files, you can use an array, and the items will be joined with `&&`.