"""Line endings (2026-11-12): every tracked text file outside the fixtures is LF. .gitattributes defaults every file to `text=auto eol=lf`, so git stores and checks out text as LF whatever wrote it, file types not invented yet included. Binaries are never converted. tests/fixtures/** is -text: recorded bytes (Blastware's own reports and exports, captures, event files) stay exactly as recorded, CRLF and all. The protocol reference and seismo_lab.py were CRLF until 5dff54b, so any rewrite outside the Edit tool turned them into whole-file diffs, and merges into them had to be resolved byte by byte. """ from __future__ import annotations import shutil import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parent.parent FIXTURES = "tests/fixtures/" pytestmark = pytest.mark.skipif( shutil.which("git") is None or not (ROOT / ".git").exists(), reason="not a git checkout") def _git(*args: str) -> str: return subprocess.run(["git", "-C", str(ROOT), *args], capture_output=True, text=True, check=True).stdout def crlf_files(include_fixtures: bool = False) -> list: """Tracked files stored (in the index) with CRLF or mixed line endings.""" out = [] for line in _git("ls-files", "--eol").splitlines(): meta, path = line.split("\t", 1) if meta.split()[0] in ("i/crlf", "i/mixed") and (include_fixtures or not path.startswith(FIXTURES)): out.append(path) return out def attr(name: str, path: str) -> str: return _git("check-attr", name, "--", path).rsplit(": ", 1)[-1].strip() def test_no_tracked_file_outside_the_fixtures_is_crlf(): assert crlf_files() == [] @pytest.mark.parametrize("path", ["sfm/new_module.py", "docs/notes.md", "Dockerfile", "events.jsonl", ".gitignore", "deploy/sfm.service", "a.kind-of-file-not-invented-yet"]) def test_any_text_file_is_stored_as_lf(path): assert (attr("text", path), attr("eol", path)) == ("auto", "lf") @pytest.mark.parametrize("path", ["tests/fixtures/minimate-bench-10-26-26-blastware/blastware/K441LTOG.000", "tests/fixtures/decode-checker-10-29-26/M007HVWF_K30W_XML.XML", "tests/fixtures/new-bench/README.md"]) def test_fixtures_are_never_converted(path): assert attr("text", path) == "unset" @pytest.mark.parametrize("path", ["parsers/raw_bw.bin", "analysis_idf/thor_report.pdf", "docs/photo.png", "docs/photo.jpg", "out/event.h5", "out/event.a5.pkl", "sfm/data/cache.db"]) def test_binaries_are_never_converted(path): assert attr("text", path) == "unset"