Skip to content

test(diff): pin the shape detectors, the structural index lines and the GNU roots - #3923

Merged
KuSh merged 1 commit into
developfrom
test/diff-mutation-gaps
Sep 11, 2026
Merged

KuSh merged 1 commit into
developfrom
test/diff-mutation-gaps

Conversation

@KuSh

@KuSh KuSh commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

A fresh mutation run against develop (85 compiling mutants, 70 killed — 82%) put
the surviving gaps in three places. This pins all three, and factors out the one
that could not be tested where it stood.

The shape detectors reject nothing

Every fixture in the diff corpus is a real capture, so the detectors only ever see
well-formed lines. Loosening && to ||:

  • is_mbox_from — any From -prefixed line over 40 characters opens an mbox
    message region. Ordinary commit prose reaches that shape.
  • is_hg_echo — a non-hex revision (diff -r zzzzzzzzzzzz …) reads as an hg echo.
  • is_submodule_range — a short or non-hex side of a <hex>..<hex> range passes.

None failed a test. detectors_reject_near_misses is the near-miss table.

git's index lines are structure, not prose

Collapsing the index / similarity index / dissimilarity index chain to a
single term left every test green, because dropped_line is only consulted once a
GNU echo has been seen — and no fixture carries both producers. A stream that does:

diff -ru a/z.txt b/z.txt        →  develop:  [file] b/z.txt (+1 -1)
...                                          [file] g.txt   (+1 -1)
diff --git a/g.txt b/g.txt
index 1234567..89abcde 100644   →  collapsed: raw passthrough, whole stream

Safe (the fallback is raw) but a silent savings regression on a section that parses.

The GNU roots were collected twice

The same eight lines were inlined in the header-pair arm and again in the
Binary files arm. Mutating either copy changed no output, because nothing reaches
that logic directly — the Only in split resolves through paths that do not depend
on it. Extracted as record_gnu_roots, which is the point of the factorisation:
the dedup and the non-empty guard become assertable, and both are now pinned. A
third arm growing a third copy is no longer the default.

No behaviour change

Byte-identical to develop across the 81 diff fixtures, 300 real git show
streams, and GNU directory diffs over names holding : and '. Each new test was
verified to fail against the mutation it exists for, and against nothing else.

Also rewrites condense_stdin's doc comment, which named a rejected alternative,
described guard::never_worse's signature from a file that does not call it, and
repeated the ANSI-view clause already carried by condense_unified_diff_strict's
own doc — per CONTRIBUTING.md's "No obvious comments".

@KuSh
KuSh force-pushed the test/diff-mutation-gaps branch from 5a77caf to 551e26f Compare September 8, 2026 00:53
@KuSh KuSh changed the title test(diff): pin the classic-diff renderer and the shape detectors test(diff): reject near-misses in the mbox, hg and submodule detectors Sep 8, 2026
@KuSh
KuSh force-pushed the test/diff-mutation-gaps branch from 551e26f to a542d65 Compare September 8, 2026 01:20
@KuSh KuSh changed the title test(diff): reject near-misses in the mbox, hg and submodule detectors test(diff): pin the shape detectors, the structural index lines and the GNU roots Sep 8, 2026
…he GNU roots

Every fixture in the diff corpus is a real capture, so the shape detectors only
ever see well-formed lines and nothing asserted what they reject. Loosening `&&`
to `||` in `is_mbox_from` makes any `From `-prefixed line over 40 characters open
an mbox message region, which ordinary commit prose reaches; the same loosening
accepts a non-hex revision in `is_hg_echo` and a short or non-hex side of a
`Submodule` range. None of those failed a test.

git's `index` and `similarity index` lines are structure, not prose. Counting one
as a dropped line costs nothing on a git-only stream, because nothing consults the
drop until a GNU echo has been seen -- but a stream carrying both producers then
bails to raw on a section that parses. Collapsing that prefix chain to a single
term left every test green.

The roots GNU diff was given were collected by the same eight lines inlined in two
arms, and mutating either copy changed no output because no unit reached them
directly. Extracted as `record_gnu_roots`, which makes the dedup and the non-empty
guard assertable; both are now pinned.

No behaviour change: byte-identical to develop across the 81 diff fixtures, 400
`git show` streams and GNU directory diffs over names holding `: ` and `'`.

Also rewrites `condense_stdin`'s doc comment, which named a rejected alternative,
described `guard::never_worse`'s signature from a file that does not call it, and
repeated the ANSI-view clause carried by `condense_unified_diff_strict`'s own doc.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@KuSh
KuSh force-pushed the test/diff-mutation-gaps branch from a542d65 to a7cc787 Compare September 8, 2026 01:25
@aeppling

Copy link
Copy Markdown
Contributor

LGTM.

Verified behaviour-preserving rather than taking the claim on trust: built the head and its merge base from the same tree and compared rtk diff - output byte-for-byte (stdout and exit code) over ~131k inputs:

  • the 186 fixtures shipped in tests/fixtures/
  • ~1,200 real git show streams from 400 commits of this repo, in plain, --color=always and --submodule=log form
  • ~80k generated git / GNU diff -r / hg / svn / mbox streams, weighted toward the shapes this PR touches, mutated with CRLF, BOM, ANSI, mid-stream truncation and invalid UTF-8

Zero divergences.

The corpus has proven power over the code you touched, not just coverage of it: mutating the index chain to && diverges 73x, is_mbox_from to || diverges 38x.

@aeppling aeppling self-assigned this Sep 11, 2026
@KuSh
KuSh merged commit bc1108b into develop Sep 11, 2026
17 checks passed
@KuSh
KuSh deleted the test/diff-mutation-gaps branch September 11, 2026 18:08
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants