llamacppctl/tests/test_build_archive.py

40 lines
1.6 KiB
Python
Raw Normal View History

"""Smoke test for the archive builder (build_archive.py).
Guards the packaging manifest and dependency parsing so regressions -- a moved
or renamed file, a broken REQUIRED_FILES entry, or the requirements/pyproject
dependency handling -- fail here in the normal test run instead of only
surfacing at release time. Runs the pure build steps (no network, no pip).
"""
import tarfile
from pathlib import Path
import build_archive
# build_archive.py lives at the repo root, so its directory is the project root.
PROJECT_ROOT = Path(build_archive.__file__).resolve().parent
def test_build_archive_builds_and_verifies(tmp_path):
out = tmp_path / "llamacppctl-test.tar.gz"
# Manifest + dependency declaration must be consistent with the real tree.
build_archive.verify_required_files(PROJECT_ROOT)
deps = build_archive.verify_dependencies_declared(PROJECT_ROOT)
assert deps, "expected runtime dependencies declared in pyproject.toml"
# Build the tarball and re-open it to verify every required file is present.
build_archive.build_tarball(PROJECT_ROOT, out)
build_archive.verify_tarball(out)
assert out.is_file()
with tarfile.open(out) as tar:
names = set(tar.getnames())
root = build_archive.ARCHIVE_ROOT_NAME
# Docs moved under docs/; LICENSE ships at the archive root; package present.
assert f"{root}/docs/BEDIENUNGSANLEITUNG.md" in names
assert f"{root}/docs/INSTALL_FROM_ARCHIVE.md" in names
assert f"{root}/docs/SECURITY_AND_OPERATIONS.md" in names
assert f"{root}/LICENSE" in names
assert f"{root}/src/llamacppctl/main.py" in names