Skip to content

docs(tests): warn that a styled inline snapshot bakes a feature into it - #3920

Merged
max-sixty merged 2 commits into
mainfrom
daily/review-runs-32945594256
Aug 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
daily/review-runs-32945594256

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

tests/CLAUDE.md tells a test that checks formatted output to use an inline snapshot, and says nothing about the fact that a snapshot of styled output also bakes the syntax-highlighting feature into the expectation. Following that rule on highlighted output is what took main's nightly red overnight: #3908's second commit converted three contains checks on render_markdown_in_help to inline snapshots, one of them covering a trailing console block, merged green, and feature-powerset failed on the next cron (run 32935569443). This adds the caveat to the section that gave the instruction, with the per-configuration shape #3916 uses to fix that test. Docs only — pre-commit run --files tests/CLAUDE.md passes.

Why here, and the full chain

The chain

When What
08-25 06:36Z #3908 opened — fix(help): treat an HTML comment inside a code block as content, test asserted with three contains calls
08-25 06:45Z Self-review cites tests/CLAUDE.md → Inline snapshots over multi-assert and pushes 8a141861a, converting them to inline snapshots. One captures the trailing console fence's rendering, which under syntax-highlighting is ESC[2mESC[0mESC[2mESC[34mwtESC[0m
08-25 16:20Z Merged
08-26 03:57Z #3916 opened, having caught the failure on an unrelated Dependabot PR
08-26 05:49Z nightly cron on e4238e83: feature-powerset red — test md_help::tests::test_html_comment_inside_a_code_block_is_content ... FAILED
08-26 06:29Z Diagnosed on #3917; #3918 filed for the same run's unrelated transient

The self-review's reasoning was right on its own terms — the contains version proves the comment line survived but says nothing about how it renders, which is what #3908 decides. What it missed is the axis on which "how it renders" is not a constant.

Why the required checks can't catch it

syntax-highlighting is a default feature, so test (linux|macos|windows), fast-checks and code-coverage all build with it on. ci's feature-check job does cargo check --bin wt --no-default-features --features cli on every PR, but cargo check never compiles #[cfg(test)] code, so the snapshot is never built there. The only job that runs the tests on that combination is feature-powerset in nightly, and nightly's gate runs on a PR only when the diff touches Cargo/toolchain/nix paths or the PR carries the nightly label — so a src/-only PR never sees it. The red is structurally deferred to the next cron on main, i.e. after the merge.

nightly.yaml's own job comment already names the failure mode — "a snapshot baking feature-dependent output, only surfaces when tests are built and run per combo" — but that text is in the workflow, not in the file an author of a unit test reads.

Why the caveat and not a gate

Gating the whole assertion on #[cfg(feature = "syntax-highlighting")] would compile the test out of the one combination that catches this class of bug. The pair form keeps the assertion on both sides and is what the repo already does elsewhere (src/styling/format.rs uses #[cfg(all(test, feature = "syntax-highlighting"))] for a module whose subject is the highlighting; here the colouring is incidental, so the test stays and only the expectation splits).

The last paragraph — apply the nightly label to a PR fixing a feature-powerset failure — is the other half of the same incident: #3916's own feature-powerset was skipped until the label went on at 06:32Z, after which it ran green on 2b734bb8. Nightly's header comment calls the label "the iteration knob for fixes targeting nightly-only failures"; nothing under tests/ said so.

Gate assessment

  • Evidence level: Critical by the table's own wording — merged code took main red. 1 occurrence, no prior sighting of this shape in the tracking log (#3691). Blast radius was small and it was self-caught within hours, which is why the proposed change is two paragraphs rather than a process.
  • Structural: yes. Any author following the snapshot rule on styled output, reading only that section, gets no warning; the information lives in nightly.yaml and Cargo.toml, neither of which a unit-test author has reason to open.
  • Cost class: wrong outward action — a red default branch, not wasted compute.
  • Change type: targeted fix (a missing caveat on an existing rule), Gate 2's normal bar.

`tests/CLAUDE.md` directs a test checking formatted output to an inline
snapshot without noting that a snapshot of styled output also pins
`syntax-highlighting`, a default feature. Following the rule on highlighted
output in #3908 merged green and took `main`'s nightly `feature-powerset` job
red, since that job is the only one running the combination without the
feature and it is skipped on a src/-only PR. Add the caveat to the section
that gave the instruction, with the per-configuration shape #3916 uses, plus
the `nightly` label knob for verifying such a fix on its own PR.
@worktrunk-bot worktrunk-bot added the review-runs Findings from the daily review-runs workflow label Aug 26, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two factual errors in the added text, both in the part that carries the explanation's weight.

feature-powerset is not the only job that runs that combination. ci.yaml's feature-check job (step "Binary builds without syntax-highlighting") runs cargo check --bin wt --no-default-features --features cli on every PR, unconditionally. The reason it doesn't catch a feature-dependent snapshot is that cargo check never compiles #[cfg(test)] code — which is exactly the distinction nightly.yaml's own job comment draws ("the check step strips dev-deps, so #[cfg(test)] code is invisible to it"), and which the PR body quotes. As written, an author who greps the workflows finds a green feature-check on the precise combination the doc says nothing runs, and concludes either that the doc is wrong or that their snapshot is already covered. Fixing this costs a clause and makes the section's claim survive a grep.

cargo insta test --accept cannot fill both arms. Under any one feature configuration only one arm of the #[cfg] pair compiles, so a single --accept fills that arm and leaves the other sitting at @"". Filling the pair takes two runs — cargo insta test --accept, then the same command with --no-default-features --features cli --bin wt (I checked: cargo insta test forwards --no-default-features, -F/--features, and --bin). The repro line offers cargo test …, which surfaces the failure but doesn't fill anything. Someone following this section literally ends up with a half-filled pair and reproduces the exact nightly red the section exists to prevent, which makes this the more consequential of the two.

Otherwise the claims check out: default = ["cli", "syntax-highlighting"], the nightly gate really does OR the label against the Cargo/toolchain paths filter, md_help is a module of the wt bin so --bin wt is the right target, and "colour" matches existing spelling in src/.

Comment thread tests/CLAUDE.md Resolved
Comment thread tests/CLAUDE.md Resolved
Comment thread tests/CLAUDE.md Resolved
feature-check does run --no-default-features --features cli on every PR;
what lets a styled snapshot through is cargo check not compiling
#[cfg(test)] code. And one --accept fills only the arm that compiles, so
the pair needs two runs.
@max-sixty
max-sixty merged commit 7f5d245 into main Aug 26, 2026
45 checks passed
@max-sixty
max-sixty deleted the daily/review-runs-32945594256 branch August 26, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-runs Findings from the daily review-runs workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants