feat: support multiple commands on iOS (#2432)
* feat: support multiple commands on iOS Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Move split_command into a util module * (unrelated) fix test docstring * Implement short-circuit behaviour on test-command --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
f8168e2a89
commit
ea08120e25
+38
-2
@@ -86,7 +86,7 @@ def test_ios_platforms(tmp_path, build_config, monkeypatch, capfd):
|
||||
"CIBW_BUILD": "cp313-*",
|
||||
"CIBW_XBUILD_TOOLS": "does-exist",
|
||||
"CIBW_TEST_SOURCES": "tests",
|
||||
"CIBW_TEST_COMMAND": "python -m unittest discover tests test_platform.py",
|
||||
"CIBW_TEST_COMMAND": "python -m this && python -m unittest discover tests test_platform.py",
|
||||
"CIBW_BUILD_VERBOSITY": "1",
|
||||
**build_config,
|
||||
},
|
||||
@@ -102,6 +102,9 @@ def test_ios_platforms(tmp_path, build_config, monkeypatch, capfd):
|
||||
captured = capfd.readouterr()
|
||||
assert "'does-exist' will be included in the cross-build environment" in captured.out
|
||||
|
||||
# Make sure the first command ran
|
||||
assert "Zen of Python" in captured.out
|
||||
|
||||
|
||||
@pytest.mark.serial
|
||||
def test_no_test_sources(tmp_path, capfd):
|
||||
@@ -134,7 +137,10 @@ def test_no_test_sources(tmp_path, capfd):
|
||||
|
||||
|
||||
def test_ios_testing_with_placeholder(tmp_path, capfd):
|
||||
"""Build will run tests with the {project} placeholder."""
|
||||
"""
|
||||
Tests with the {project} placeholder are not supported on iOS, because the test command
|
||||
is run in the simulator.
|
||||
"""
|
||||
skip_if_ios_testing_not_supported()
|
||||
|
||||
project_dir = tmp_path / "project"
|
||||
@@ -159,6 +165,36 @@ def test_ios_testing_with_placeholder(tmp_path, capfd):
|
||||
assert "iOS tests cannot use placeholders" in captured.out + captured.err
|
||||
|
||||
|
||||
@pytest.mark.serial
|
||||
def test_ios_test_command_short_circuit(tmp_path, capfd):
|
||||
skip_if_ios_testing_not_supported()
|
||||
|
||||
project_dir = tmp_path / "project"
|
||||
basic_project = test_projects.new_c_project()
|
||||
basic_project.files.update(basic_project_files)
|
||||
basic_project.generate(project_dir)
|
||||
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
# `python -m not_a_module` will fail, so `python -m this` should not be run.
|
||||
utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
"CIBW_PLATFORM": "ios",
|
||||
"CIBW_BUILD": "cp313-*",
|
||||
"CIBW_XBUILD_TOOLS": "",
|
||||
"CIBW_TEST_SOURCES": "tests",
|
||||
"CIBW_TEST_COMMAND": "python -m not_a_module && python -m this",
|
||||
"CIBW_BUILD_VERBOSITY": "1",
|
||||
},
|
||||
)
|
||||
|
||||
captured = capfd.readouterr()
|
||||
|
||||
assert "No module named not_a_module" in captured.out + captured.err
|
||||
# assert that `python -m this` was not run
|
||||
assert "Zen of Python" not in captured.out + captured.err
|
||||
|
||||
|
||||
def test_missing_xbuild_tool(tmp_path, capfd):
|
||||
"""Build will fail if xbuild-tools references a non-existent tool."""
|
||||
skip_if_ios_testing_not_supported()
|
||||
|
||||
Reference in New Issue
Block a user