Raxol. Harness. Surface. GoldenDiff
(Raxol v2.6.1)
View Source
A pure, small diff formatter for the byte-golden snapshot tests
(test/harness/golden_snapshot_test.exs). Golden byte streams are
tens of kilobytes; a raw assert rendered == golden on a mismatch
would dump the whole binary into the test failure message. This module
exists so a divergence reports exactly one thing: the first byte
offset the two streams disagree at, plus a small, escaped context
window around it -- never the full streams.
Written RED-FIRST (see test/harness/golden_diff_test.exs, which was
authored and run against a not-yet-existing module before this file
was written, per this proposal's red-first discipline for pure diff
logic).
Summary
Functions
Compares expected (the checked-in golden) against actual (a fresh
render). Returns :ok on byte equality, or {:diverged, offset, report} where offset is the first byte index the two binaries
disagree at (or, for a proper-prefix pair, min(byte_size(expected), byte_size(actual)) -- the point where the shorter side simply ends)
and report is a bounded, human-readable string.
Functions
@spec compare(binary(), binary()) :: :ok | {:diverged, non_neg_integer(), String.t()}
Compares expected (the checked-in golden) against actual (a fresh
render). Returns :ok on byte equality, or {:diverged, offset, report} where offset is the first byte index the two binaries
disagree at (or, for a proper-prefix pair, min(byte_size(expected), byte_size(actual)) -- the point where the shorter side simply ends)
and report is a bounded, human-readable string.