Files
cibuildwheel/test/test_build_frontend_args.py
T

43 lines
1.3 KiB
Python
Raw Normal View History

2023-08-26 19:37:29 +01:00
import subprocess
2026-04-01 10:23:02 -04:00
from pathlib import Path
2023-08-26 19:37:29 +01:00
import pytest
from . import test_projects, utils
2023-08-26 19:37:29 +01:00
2024-05-28 05:31:36 -07:00
@pytest.mark.parametrize(
"frontend_name",
[
pytest.param("pip", marks=utils.skip_if_pyodide("No pip for pyodide")),
"build",
],
)
2026-04-01 10:23:02 -04:00
def test_build_frontend_args(
tmp_path: Path, capfd: pytest.CaptureFixture[str], frontend_name: str
) -> None:
project = test_projects.new_c_project()
2023-08-26 19:37:29 +01:00
project_dir = tmp_path / "project"
project.generate(project_dir)
# the build will fail because the frontend is called with '-h' - it prints the help message
2024-05-28 05:31:36 -07:00
add_env = {"CIBW_BUILD_FRONTEND": f"{frontend_name}; args: -h"}
2025-05-16 11:11:16 +01:00
if utils.get_platform() == "pyodide":
2024-05-28 05:31:36 -07:00
add_env["TERM"] = "dumb" # disable color / style
2025-05-14 10:06:34 -04:00
add_env["NO_COLOR"] = "1"
2023-08-26 19:37:29 +01:00
with pytest.raises(subprocess.CalledProcessError):
2024-05-28 05:31:36 -07:00
utils.cibuildwheel_run(project_dir, add_env=add_env, single_python=True)
2023-08-26 19:37:29 +01:00
captured = capfd.readouterr()
print(captured.out)
# check that the help message was printed
if frontend_name == "pip":
assert "Usage:" in captured.out
assert "Wheel Options:" in captured.out
2025-05-16 11:11:16 +01:00
elif utils.get_platform() == "pyodide":
2024-05-28 05:31:36 -07:00
assert "Usage: pyodide build" in captured.out
2023-08-26 19:37:29 +01:00
else:
assert "usage:" in captured.out
assert "A simple, correct Python build frontend." in captured.out