|
1 | 1 | import subprocess |
| 2 | +import textwrap |
2 | 3 | from contextlib import nullcontext as does_not_raise |
3 | 4 |
|
4 | 5 | import pytest |
@@ -56,3 +57,42 @@ def test(tmp_path, capfd): |
56 | 57 | # We only produced one wheel (perhaps Pyodide) |
57 | 58 | # check that it has the right name |
58 | 59 | assert result[0].startswith("spam-0.1.0-py2-none-") |
| 60 | + |
| 61 | + |
| 62 | +@pytest.mark.parametrize( |
| 63 | + "repair_command", |
| 64 | + [ |
| 65 | + "python repair.py {wheel} {dest_dir}", |
| 66 | + "python {package}/repair.py {wheel} {dest_dir}", |
| 67 | + "python {project}/repair.py {wheel} {dest_dir}", |
| 68 | + ], |
| 69 | + ids=["no-placeholder", "package-placeholder", "project-placeholder"], |
| 70 | +) |
| 71 | +def test_repair_wheel_command_structure(tmp_path, repair_command): |
| 72 | + project_dir = tmp_path / "project" |
| 73 | + project = test_projects.new_c_project() |
| 74 | + project.files["repair.py"] = textwrap.dedent(""" |
| 75 | + import shutil |
| 76 | + import sys |
| 77 | + from pathlib import Path |
| 78 | +
|
| 79 | + wheel = Path(sys.argv[1]) |
| 80 | + dest_dir = Path(sys.argv[2]) |
| 81 | +
|
| 82 | + dest_dir.mkdir(parents=True, exist_ok=True) |
| 83 | + shutil.copy(wheel, dest_dir / "spamrepaired-0.0.1-py-none-any.whl") |
| 84 | + """) |
| 85 | + |
| 86 | + # Combined test for repair wheel command formats (plain, {package}, {project}) |
| 87 | + project.generate(project_dir) |
| 88 | + |
| 89 | + result = utils.cibuildwheel_run( |
| 90 | + project_dir, |
| 91 | + add_env={ |
| 92 | + "CIBW_REPAIR_WHEEL_COMMAND": repair_command, |
| 93 | + "CIBW_ARCHS": "native", |
| 94 | + }, |
| 95 | + single_python=True, |
| 96 | + ) |
| 97 | + |
| 98 | + assert result == ["spamrepaired-0.0.1-py-none-any.whl"] |
0 commit comments