mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-22 23:22:18 +01:00
The installer ships as the steam_installer package beside steam_backlog_enforcer, with its tests, docs and Proton lock. The enforcer's fast install now starts the installer from this checkout. Both appinfo.vdf readers share one key-value decoder (steam_installer.appinfo_kv), and the duplicated test fixtures and helpers are folded into conftest and _cli_helpers so the whole-tree duplicate-code check is clean. check_requirements_sync treats sibling packages as first-party. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZCxnNWLtpVwFLVk9w
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
"""install_deps.sh --check-only: what a run needs; steamcmd is gone from it."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
from typing import TYPE_CHECKING
|
|
|
|
from steam_installer.tests._run_helpers import run_captured
|
|
|
|
if TYPE_CHECKING:
|
|
import subprocess
|
|
|
|
PKG = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
BASH = shutil.which("bash") or "bash"
|
|
|
|
|
|
def _stub(bin_dir: Path, name: str, script: str) -> None:
|
|
path = bin_dir / name
|
|
path.write_text(f"#!/bin/bash\n{script}\n")
|
|
path.chmod(0o755)
|
|
|
|
|
|
def _check_only(
|
|
tmp_path: Path, *, libibus_installed: bool, proton_ok: bool = True
|
|
) -> subprocess.CompletedProcess[str]:
|
|
bin_dir = tmp_path / "bin"
|
|
bin_dir.mkdir()
|
|
_stub(bin_dir, "depotdownloader", "exit 0")
|
|
_stub(
|
|
bin_dir,
|
|
"pacman",
|
|
f'[[ "$*" == "-Q libibus" ]] && exit {0 if libibus_installed else 1}; exit 0',
|
|
)
|
|
# The real `--check` would look at the developer's own Steam tree.
|
|
_stub(bin_dir, "python3", f"exit {0 if proton_ok else 1}")
|
|
env = {
|
|
**os.environ,
|
|
"PATH": f"{bin_dir}:/usr/bin:/bin",
|
|
"HOME": str(tmp_path),
|
|
"SGI_PYTHON": str(bin_dir / "python3"),
|
|
}
|
|
return run_captured([BASH, str(PKG / "install_deps.sh"), "--check-only"], env)
|
|
|
|
|
|
def test_missing_libibus_is_reported_and_steamcmd_is_not_needed(tmp_path: Path) -> None:
|
|
"""Missing libibus is reported and steamcmd is not needed."""
|
|
result = _check_only(tmp_path, libibus_installed=False)
|
|
assert result.returncode == 1
|
|
assert "missing: libibus" in result.stderr
|
|
assert "steamcmd" not in result.stdout + result.stderr
|
|
|
|
|
|
def test_all_present_without_steamcmd(tmp_path: Path) -> None:
|
|
"""All present without steamcmd."""
|
|
result = _check_only(tmp_path, libibus_installed=True)
|
|
assert result.returncode == 0, result.stderr
|
|
assert "All dependencies present." in result.stdout
|
|
|
|
|
|
def test_run_sh_rechecks_when_the_proton_pin_changes() -> None:
|
|
"""A stale stamp must not hide a lock bump or a deleted tool folder."""
|
|
text = (PKG / "run.sh").read_text()
|
|
assert "proton-native.lock" in text
|
|
assert "steam_installer.proton_native --check" in text
|
|
|
|
|
|
def test_missing_native_proton_is_reported(tmp_path: Path) -> None:
|
|
"""Missing native proton is reported."""
|
|
result = _check_only(tmp_path, libibus_installed=True, proton_ok=False)
|
|
assert result.returncode == 1
|
|
assert "missing: proton-cachyos-native" in result.stderr
|