Repository navigation
test: pin the CLI README's pasted --help block to the rendered long help - #379
Conversation
The pasted $ fasterhenry --help block in fasterhenry-cli/README.md had drifted from the binary: the --fasthenry-compat description was missing its trailing clause. Fix that line, and add an in-process test that extracts the pasted block from the README (include_str!), renders BareCli's long help in-process, and compares line by line with trailing whitespace stripped from both sides. The failure names the first differing line and shows both sides; a moved fence or a length mismatch fails loudly rather than comparing nothing. Closes #356
|
PR #379's |
|
✅ Approved! Two-file diff, exactly the scope the issue's recorded decision (option (a) — keep the paste, pin it with a test) asks for: one README line and one in-process test in the existing Spec reconciliationReviewed against #356's current body (post re-curation) and all trusted comments. No material difference between the current requirements and this PR's scope: the live spec asks for one README line (73), a whole-block comparison with Verification I ran (worktree
|
| AC | Status |
|---|---|
| Block matches rendered long help, trailing whitespace stripped | ✅ test green, 47 vs 47 |
| A test fails when the two drift | ✅ demonstrated against the merge-base README |
| Failure names the first differing line and shows both sides | ✅ captured above; length mismatch covered too |
cargo test --workspace + Package job green |
✅ via CI at c719c39 |
| No trailing whitespace introduced | ✅ measured, none in the file |
Closes #356 present, and it is the only close/fix/resolve keyword adjacent to a #356 reference in the body — no stray second one.
Code quality notes (non-blocking, no action needed)
- The extraction's
take_while(|&&line| line != "```")would stop early if the help output itself ever emitted a bare```line. That degrades into the length assertion, which fails loudly — the safe direction, and clap will not emit one. Worth leaving as-is rather than hardening. position(...)takes the first$ fasterhenry --helpmarker, so a second pasted block elsewhere in the README would be silently unpinned. Not a defect today (there is one block) and out of this issue's scope; not worth an issue.- Comparing per-line with an explicit length check (rather than one whole-string
assert_eq!) is what makes the failure message useful here. Good call.
Nice, tightly-scoped change that converts a twice-hand-fixed wart into an enforced invariant.
|
PR #379's |
|
Champion Auto-Merge This PR meets all safety criteria for automatic merging:
Proceeding with merge... If this was merged in error, you can revert with: Automated by Champion role |
Pins the
$ fasterhenry --helpblock pasted infasterhenry-cli/README.md(the crate's crates.io landing page) to the command's real rendered long help, per the issue's decided option (a): keep the paste, pin it with a test.Changes
fasterhenry-cli/README.md— one line: the--fasthenry-compatdescription (line 73) gains the missing trailing clause ", and turns a.equivof a node with itself into a warning", matchingcli.rs's doc comment as clap actually renders it (no trailing period — clap strips it; verified against the built binary). The ten-trailing-space gap on line 69 is deliberately untouched: it is absorbed by the comparison's trailing-whitespace normalization, and the file carries no trailing whitespace anywhere.fasterhenry-cli/tests/cli.rs— newreadme_help_block_matches_rendered_long_help: reads the README at compile time (include_str!), extracts the block between$ fasterhenry --helpand the closing fence (asserting it found a non-empty block), rendersBareCli::command().render_long_help()in-process (byte-identical to the binary's--help), and compares whole-output, per line, withtrim_end()on both sides plus an explicit length check. The failure names the first differing line (block-relative and absolute README line) and shows both sides. No workflow change;tests/is outside the crate'sincludeallowlist, so thePackage (cargo publish --dry-run)job is unaffected.Acceptance Criteria Verification
diffof the extracted block against freshtarget/debug/fasterhenry --helpoutput (47 vs 47, clean undersed -E 's/[[:space:]]+$//'normalization) and the new test passing.README help block line 39 (README line 73) differs:with both lines in full.cargo test -p fasterhenry-cli --test cli— 20 passed (19 existing + new). Fullcargo test --workspaceand the Package job are CI's gate; locally the crate'sincludeallowlist (src/**/*.rs,build.rs,README.md,LICENSE,CHANGELOG.md) still excludestests/, and CI's exactcargo fmt --all --checkandcargo clippy --workspace --all-targets -- -D warningsboth pass clean in this worktree.grep -rn '[[:space:]]$' fasterhenry-cli/README.mdfinds none.Test Plan
readme_help_block_matches_rendered_long_helpfirst, ran it against the still-drifted README, and captured the failure naming README line 73 with both sides shown; then made the one-line README edit and the test went green.$ fasterhenry --helpmarker fires the extractionexpect. Both mutations restored; final tree has exactly the one-line README fix.diff <(extracted README block) <(fresh binary --help)after trailing-whitespace normalization — identical.Closes #356
loom dashboard