Skip to content

action_reference_doc_is_current prints two 44 KB documents instead of the line that differs #345

Description

@vladimirrott

Re-measured 2026-09-09 at 5673d20. Two figures moved and are corrected
throughout the body below: the assert_eq! sits at line 163, and
docs/action-reference.md is 44,163 bytes. Still 399 lines, and the
defect is unchanged. #384 moved the line.

$ git rev-parse --short=8 HEAD
5673d20f
$ grep -n 'assert_eq!' crates/sysknife-daemon/tests/action_reference_doc.rs
163:    assert_eq!(
$ wc -l -c docs/action-reference.md
  399 44163 docs/action-reference.md

crates/sysknife-daemon/tests/action_reference_doc.rs:163 compares two 44 KB documents with assert_eq!:

let committed = std::fs::read_to_string(&path).unwrap_or_default();
assert_eq!(
    committed, generated,
    "docs/action-reference.md is out of date with the action catalogue. \
     Regenerate: UPDATE_ACTION_REFERENCE=1 cargo test -p sysknife-daemon \
     --test action_reference_doc"
);

docs/action-reference.md is 399 lines and 44,163 bytes. When it fails, the panic prints both sides, so the contributor scrolls 88 KB of near-identical Markdown to find the line that moved.

Why it matters

The message names the fix, which is the important half and already right. What it does not say is what differs, and that decides whether the contributor trusts it. Someone who added one action sees a wall of text and cannot tell at a glance whether the regeneration is safe to accept or whether they broke something else.

It also misreports a mangled checkout. A CRLF working tree fails this assertion on line endings alone and says the catalogue is out of date, which is how #341 came to report it as a pre-existing failure on main. That half belongs to the line-endings issue; this one is about the message.

Scope

Fail with the first differing line and its number, then the regeneration command. Something like:

docs/action-reference.md is out of date with the action catalogue.
First difference at line 212:
  committed: | `AptUpgrade` | HIGH | yes |
  generated: | `AptUpgrade` | HIGH | no  |
Regenerate: UPDATE_ACTION_REFERENCE=1 cargo test -p sysknife-daemon --test action_reference_doc

zip over the two line iterators covers it, plus a length check so a truncated file reports the missing tail rather than nothing.

Tests first

The interesting assertion is about the message, so drive the comparison helper directly rather than through the file: feed it two strings that differ at a known line and assert the rendered message names that line number and both sides. A test that only checks the equal case proves nothing about the failure path, which is the whole feature.

Difficulty

easy, and self-contained in one file.

Getting started

CONTRIBUTING.md has the build and test commands. No CLA and no copyright waiver. The project is MIT.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimedSomeone has said in the thread that they are working on thiseasyDifficulty: self-contained, no deep context neededenhancementNew feature or requestgood first issueGood for newcomerstwir-listedListed in a This Week in Rust CfP. Do not offer to anyone until that issue publishes.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions