test(propose): pin the default artifact with a committed golden
This commit is contained in:
parent
798f64ad6b
commit
c97e250f69
3 changed files with 140 additions and 0 deletions
|
|
@ -52,6 +52,42 @@ Hovedbaeresystemet skal ha R60 dokumentert baereevne.
|
|||
"""
|
||||
|
||||
|
||||
#: The golden fixture's document. It carries a BARE-INTEGER ascending run of
|
||||
#: three (`1`, `2`, `3`), which today's rules do not match at all -- measured,
|
||||
#: bare `1` / `1.` / `1)` yield 0 candidates. That is precisely why the golden
|
||||
#: is taken over THIS text and not over `DOCUMENT`: `DOCUMENT` has no
|
||||
#: bare-integer line, so a golden over it would stay byte-identical even if the
|
||||
#: outline rule were accidentally defaulted ON, and the guard would be a trap
|
||||
#: written down but never able to fire. The ATX heading and the dotted heading
|
||||
#: are here so the shipping rules fire too, and the golden pins their output as
|
||||
#: well as the outline rule's absence.
|
||||
OUTLINE_DOCUMENT = """# Stange skole -- teknisk grunnlag
|
||||
|
||||
Innledende tekst som gir dokumentet en kropp foer kapitlene begynner.
|
||||
|
||||
1 Innledning
|
||||
|
||||
Bakgrunnen for prosjektet og omfanget av arbeidet.
|
||||
|
||||
2 Krav
|
||||
|
||||
Krav til seksjonering av bygget over flere etasjer.
|
||||
|
||||
3 Gjennomfoering
|
||||
|
||||
Framdrift, faser og overlevering av bygget.
|
||||
|
||||
1.1 Brannkonsept
|
||||
|
||||
To uavhengige roemningsveier fra hver branncelle.
|
||||
"""
|
||||
|
||||
#: Frozen in the golden's bytes. An explicit argument because the artifact
|
||||
#: carries it verbatim, and a wall-clock default would make the golden
|
||||
#: unreproducible by construction.
|
||||
GOLDEN_PROPOSED_AT = "2026-09-03T00:00:00Z"
|
||||
|
||||
|
||||
def write(tmp_path: Path, text: str = DOCUMENT, name: str = "n500.md") -> Path:
|
||||
path = tmp_path / name
|
||||
path.write_text(text, encoding="utf-8", newline="")
|
||||
|
|
@ -511,3 +547,31 @@ def test_an_unbreakable_line_longer_than_the_cap_is_still_cut(
|
|||
for entry in plan["entries"]:
|
||||
start, end = entry["span"]
|
||||
assert end - start <= 3000
|
||||
|
||||
|
||||
# --- the default profile, pinned byte for byte ----------------------------
|
||||
#
|
||||
# The one guard that can go red on an accidental default-on regression of any
|
||||
# rule added later. It compares the WHOLE artifact, so a new candidate, a moved
|
||||
# span, a changed `derived` list or a renamed path all break it.
|
||||
|
||||
|
||||
def test_the_default_artifact_matches_its_committed_golden(tmp_path: Path) -> None:
|
||||
"""The default profile is a promise to consumers; this is what keeps it.
|
||||
|
||||
The golden transitively pins `observed_extractor_version` too, so a
|
||||
converter bump turns this red. That is a legitimate red, not a defect:
|
||||
read the diff and decide, per `tests/fixtures/README.md`.
|
||||
"""
|
||||
source = write(tmp_path, OUTLINE_DOCUMENT, "outline.md")
|
||||
out = tmp_path / "outline-plan.json"
|
||||
assert (
|
||||
okf_propose_segments.main(
|
||||
[str(source), "--out", str(out), "--proposed-at", GOLDEN_PROPOSED_AT]
|
||||
)
|
||||
== 0
|
||||
)
|
||||
golden = Path(__file__).parent / "fixtures" / "propose-golden-default.json"
|
||||
assert out.read_bytes() == golden.read_bytes(), (
|
||||
"the default artifact diverges from its committed golden bytes"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue