Files
cibuildwheel/test/test_troubleshooting.py
T

63 lines
1.9 KiB
Python
Raw Normal View History

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
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])
def test_failed_build_with_so_files(tmp_path, capfd, build_frontend_env, project_contains_so_files):
project = TestProject()
project.files["setup.py"] = "raise Exception('this build will fail')\n"
if project_contains_so_files:
project.files["libnothing.so"] = ""
2021-05-03 11:45:43 -04:00
if utils.platform != "linux":
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])
def test_failed_repair_with_so_files(tmp_path, capfd, project_contains_so_files):
if utils.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