test(md_help): expect the guttered console block per syntax-highlighting - #3916
Conversation
`test_html_comment_inside_a_code_block_is_content` baked the highlighted rendering of its trailing `console` block into one inline snapshot. With `syntax-highlighting` off — the `--no-default-features --features cli` combination — that block renders plain, so `cargo hack test --feature-powerset` failed on a test whose subject is marker containment, not highlighting. Split the expectation the way `src/styling/format.rs` already does, with a `#[cfg(feature = ...)]` / `#[cfg(not(...))]` pair, so both configurations keep the assertion instead of one of them dropping it.
|
One thing worth flagging: So the verification is the local run in the PR body, not a check on this head: |
|
The nightly cron on Same test, same feature combination as this PR fixes, so no separate fix PR — this one covers it. Adding the The run's other failure is unrelated
|
…it (#3920) `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](https://github.com/max-sixty/worktrunk/actions/runs/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. <details><summary>Why here, and the full chain</summary> ## 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](#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. </details> --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
cargo hack test --feature-powersetfails on the--no-default-features --features clicombination:test_html_comment_inside_a_code_block_is_contentbaked the highlighted rendering of its trailing```consoleblock into one inline snapshot, and withsyntax-highlightingoff that block renders plain. Split the expectation into a#[cfg(feature = "syntax-highlighting")]/#[cfg(not(...))]pair — the shapesrc/styling/format.rsalready uses — so both configurations keep the assertion rather than one of them losing it. Verified by running the test under both feature sets locally.Detail
The failing diff:
syntax-highlightingis a default feature, so the required checks (test (linux|macos|windows),fast-checks) build with it on and never see this; onlyfeature-powersetexercisescliwithout it. That job's own comment innightly.yamlnames this exact case — "a snapshot baking feature-dependent output, only surfaces when tests are built and run per combo".Introduced by #3908, which landed after
main's last nightly run, so no run onmainhad caught it yet. It surfaced on #3915 (an unrelated Dependabot bump), where the red check was confusing enough to be worth clearing.The test's subject is that a fenced
<!-- wt list -->is content and its marker does not leak into the following block. Both cfg variants assert that; only the trailing block's colouring differs, which is why gating the whole assertion on the feature would have been the wrong trade.Test plan
The second command reproduces the failure at
8e40a2b7and passes here.cargo fmt --checkandcargo clippy --no-default-features --features cliare clean.