Files

76 lines
2.1 KiB
Python
Raw Permalink Normal View History

2026-05-28 00:20:08 +02:00
from __future__ import annotations
2020-08-13 11:46:39 +01:00
import subprocess
2021-01-06 13:50:58 -05:00
2020-08-13 11:46:39 +01:00
import pytest
2021-01-06 13:50:58 -05:00
2020-08-13 11:46:39 +01:00
from . import utils
from .test_projects import TestProject, new_c_project
2020-08-13 11:46:39 +01:00
2026-05-28 00:20:08 +02:00
TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path
SO_FILE_WARNING = "NOTE: Shared object (.so) files found in this project."
2020-08-13 11:46:39 +01:00
@pytest.mark.parametrize("project_contains_so_files", [False, True])
2026-04-01 10:23:02 -04:00
def test_failed_build_with_so_files(
tmp_path: Path,
capfd: pytest.CaptureFixture[str],
build_frontend_env: dict[str, str],
project_contains_so_files: bool,
) -> None:
project = TestProject()
project.files["setup.py"] = "raise Exception('this build will fail')\n"
if project_contains_so_files:
project.files["libnothing.so"] = ""
2025-05-16 11:11:16 +01:00
if utils.get_platform() != "linux":
2021-05-03 11:45:43 -04:00
pytest.skip("this test is only relevant to the linux build")
2020-08-13 11:46:39 +01:00
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
project.generate(project_dir)
2020-08-13 11:46:39 +01:00
with pytest.raises(subprocess.CalledProcessError):
2021-06-23 10:47:18 -04:00
utils.cibuildwheel_run(project_dir, add_env=build_frontend_env)
2020-08-13 11:46:39 +01:00
captured = capfd.readouterr()
2021-05-03 11:45:43 -04:00
print("out", captured.out)
print("err", captured.err)
if project_contains_so_files:
assert SO_FILE_WARNING in captured.err
else:
assert SO_FILE_WARNING not in captured.err
@pytest.mark.parametrize("project_contains_so_files", [False, True])
2026-04-01 10:23:02 -04:00
def test_failed_repair_with_so_files(
tmp_path: Path,
capfd: pytest.CaptureFixture[str],
project_contains_so_files: bool,
) -> None:
2025-05-16 11:11:16 +01:00
if utils.get_platform() != "linux":
pytest.skip("this test is only relevant to the linux build")
project = new_c_project()
if project_contains_so_files:
project.files["libnothing.so"] = ""
project_dir = tmp_path / "project"
project.generate(project_dir)
with pytest.raises(subprocess.CalledProcessError):
2021-08-28 12:38:58 +01:00
utils.cibuildwheel_run(project_dir, add_env={"CIBW_REPAIR_WHEEL_COMMAND": "false"})
captured = capfd.readouterr()
print("out", captured.out)
print("err", captured.err)
if project_contains_so_files:
assert SO_FILE_WARNING in captured.err
else:
assert SO_FILE_WARNING not in captured.err