Homebrew moves the extracted archive directory into the Caskroom without stripping the top-level name, so font artifact paths need the homebrew-fonts/ prefix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
1 KiB
Python
26 lines
1 KiB
Python
"""Verify that each font's cask references valid font files that exist."""
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from tests.conftest import CASKS_DIR, FONT_FILES_DIR, get_font_dir_names
|
|
|
|
|
|
@pytest.mark.parametrize("font_name", get_font_dir_names())
|
|
def test_cask_font_artifacts_are_installable(font_name):
|
|
"""Each font artifact in the cask points to a real TTF or OTF file."""
|
|
cask_path = CASKS_DIR / f"{font_name}.rb"
|
|
if not cask_path.exists():
|
|
pytest.skip(f"No cask for {font_name} (no TTF/OTF files)")
|
|
|
|
content = cask_path.read_text()
|
|
paths = re.findall(r'^\s*font\s+"([^"]+)"', content, re.MULTILINE)
|
|
assert paths, f"{font_name}: cask has no font artifacts"
|
|
|
|
for rel_path in paths:
|
|
local_path = rel_path.replace("homebrew-fonts/", "", 1)
|
|
full_path = FONT_FILES_DIR.parent / local_path
|
|
assert full_path.is_file(), f"{font_name}: missing font file: {rel_path}"
|
|
assert full_path.suffix.lower() in (".ttf", ".otf", ".ttc"), (
|
|
f"{font_name}: unexpected font type: {full_path.suffix}"
|
|
)
|