headroom/scripts/tests/test_sync_plugin_versions.py
Garm efd2ac1ca4 chore: renormalize line endings to LF
`.gitattributes` declares `*.py text eol=lf` and `*.sh text eol=lf`, but
74 files (73 .py, 1 .sh) are stored in the index with CRLF line endings,
violating that contract. Every macOS/Linux clone reports these files as
"modified" on fresh checkout because git's diff engine sees the stored
bytes don't match the attribute contract, even though the working tree
and index match byte-for-byte.

Running `git add --renormalize .` rewrites each affected blob so the
stored form matches the attribute declaration. No semantic changes —
every affected file's diff is "N insertions, N deletions" with inserts
and deletes being the same lines modulo line endings.

Follow-up commit adds `.git-blame-ignore-revs` so `git blame` / GitHub
blame skip this mechanical commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:33:30 +02:00

68 lines
2.2 KiB
Python

"""Tests for sync-plugin-versions.py."""
from __future__ import annotations
import importlib.util
from pathlib import Path
def _load_module():
script = Path(__file__).parent.parent / "sync-plugin-versions.py"
spec = importlib.util.spec_from_file_location("sync_plugin_versions", script)
assert spec is not None
assert spec.loader is not None
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def test_compute_repo_semver_uses_release_helpers(monkeypatch) -> None:
module = _load_module()
calls: dict[str, object] = {}
monkeypatch.setattr(module, "list_release_tags", lambda root: ["v0.9.0"])
monkeypatch.setattr(module, "find_latest_release_tag", lambda tags: "v0.9.0")
monkeypatch.setattr(module, "list_release_commits", lambda root, tag: ["feat: add init"])
monkeypatch.setattr(module, "determine_bump_level", lambda commits: "minor")
monkeypatch.setattr(module, "get_canonical_version", lambda root: "0.5.25")
def fake_compute_release_version(*, canonical_version: str, level: str, tags: list[str]):
calls["canonical_version"] = canonical_version
calls["level"] = level
calls["tags"] = tags
return type("Info", (), {"npm_version": "0.10.0"})()
monkeypatch.setattr(module, "compute_release_version", fake_compute_release_version)
assert module.compute_repo_semver(Path("repo")) == "0.10.0"
assert calls == {
"canonical_version": "0.5.25",
"level": "minor",
"tags": ["v0.9.0"],
}
def test_main_runs_plugin_only_version_sync(monkeypatch) -> None:
module = _load_module()
commands: list[list[str]] = []
monkeypatch.setattr(module, "compute_repo_semver", lambda root: "0.10.0")
monkeypatch.setattr(
module.subprocess,
"run",
lambda command, cwd, check: commands.append(command),
)
module.main()
assert commands == [
[
module.sys.executable,
str(module.ROOT / "scripts" / "version-sync.py"),
"--root",
str(module.ROOT),
"--version",
"0.10.0",
"--plugin-manifests-only",
]
]