test_macos_deployment_target.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """Tests for macOS runtime wheel deployment-target validation."""
  2. from __future__ import annotations
  3. import runpy
  4. from pathlib import Path
  5. from types import SimpleNamespace
  6. import pytest
  7. ROOT = Path(__file__).resolve().parents[3]
  8. SCRIPT = ROOT / "scripts" / "check-macos-deployment-target.py"
  9. checker = SimpleNamespace(**runpy.run_path(str(SCRIPT)))
  10. def test_otool_parser_uses_the_newest_macho_slice() -> None:
  11. output = """
  12. cmd LC_BUILD_VERSION
  13. minos 11.0
  14. cmd LC_BUILD_VERSION
  15. minos 13.5
  16. """
  17. assert checker.parse_otool_deployment_target(output) == (13, 5)
  18. def test_otool_parser_requires_a_deployment_target() -> None:
  19. with pytest.raises(ValueError, match="contains no LC_BUILD_VERSION"):
  20. checker.parse_otool_deployment_target("Load command 0\n")
  21. def test_wheel_tag_rejects_a_newer_executable_target() -> None:
  22. checker.ensure_compatible(Path("runtime"), (13, 5), "macosx_14_0_arm64")
  23. with pytest.raises(RuntimeError, match="requires macOS 14.1"):
  24. checker.ensure_compatible(Path("spawn-helper"), (14, 1), "macosx_14_0_arm64")