test(doc-templates): replace rotted doc line-number citations and stale template examples - #4012
Open
worktrunk-bot wants to merge 1 commit into
Open
test(doc-templates): replace rotted doc line-number citations and stale template examples#4012worktrunk-bot wants to merge 1 commit into
worktrunk-bot wants to merge 1 commit into
Conversation
…le template examples All five 'line N' citations in doc_templates.rs pointed at unrelated content, and three templates no longer matched the docs — two using variable names DEPRECATED_VARS has since renamed (worktree, main_worktree). expand_template substitutes whatever the caller's HashMap holds, so every test still passed and nothing flagged the drift. Cite section headings instead of line numbers, and realign the templates with the examples the docs currently show.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/integration_tests/doc_templates.rsexists to verify that template expressions shown in the docs behave as documented, but it had drifted from those docs on both axes: all five of itsline Ncitations now point at unrelated content, and three of its templates no longer match what the docs show — two of them using variable names the deprecation table has since renamed. Becauseexpand_templatesubstitutes whatever names the caller puts in itsHashMap, every one of these still passed, so nothing flagged the drift. This realigns the tests with the current docs and replaces the line numbers with section headings, which don't rot.Found by the nightly survey (this file was in today's rotation). Test-only, so no changelog entry — the same treatment as #3987.
The five stale citations, verified against
mainat 51fd3b2test_doc_hash_port_repo_branch_concatenationhook.mdline 176-vresolved-variables paragraphtest_doc_example_docker_postgrestips-patterns.mdlines 75-84wt listblock, then the## Database per worktreeheadingtest_doc_example_database_urltips-patterns.mdlines 96-101[[post-start]]docker blocktest_doc_example_dev_serverhook.mdlines 168-170test_doc_example_worktree_path_sanitizetips-patterns.mdline 217## LLM branch summariesheadingEach now cites the heading the example lives under —
hook.md"Worktrunk filters",tips-patterns.md"Database per worktree",tips-patterns.md"Bare repository layout".The three templates that had diverged
test_doc_basic_variablesasserted{{ worktree }}, while thehook.md"Template variables" table it names documentsworktree_path.worktreeis row 2 ofDEPRECATED_VARS. Nowworktree_path.test_doc_example_worktree_path_sanitizetested{{ main_worktree }}.{{ branch | sanitize }}, and quoted a doc line (worktree-path = "{{ branch | sanitize }}") that matches neither the citation nor the template.main_worktreeis also inDEPRECATED_VARS. The docs' actual bare-repo example isworktree-path = "{{ repo_path }}/../{{ branch | sanitize }}", which is what it now tests.The "Database per worktree" pair. The docs moved to deriving the container name and port in a
set-varsstep and referencing them as{{ vars.container }}/{{ vars.port }}, so thedocker runshape the test asserted on is gone. The two expressions it was really exercising still exist, inset-vars— sotest_doc_example_docker_postgresis renamedtest_doc_example_database_varsand points there.test_doc_example_database_urllikewise: the documenteddb_urlends in{{ branch | sanitize_db }}, not{{ repo }}.Verification
cargo test --test integration doc_templates— 16 passed.cargo fmt --checkandcargo clippy --tests -- -D warningsclean.No regression test, since the change is the test correction. I did check the one new assertion that isn't an exact equality —
test_doc_example_database_url'sstarts_with— is not vacuous: swapping the template's{{ branch | sanitize_db }}back to a plain{{ branch }}fails it, then passes again once reverted.What this does not do is prevent the next rot. A heading citation survives edits that a line number doesn't, but nothing mechanically checks that the quoted snippet still appears in the named section — these tests build their own variable maps, so they cannot fail on a docs change. A checker that greps each cited file for the quoted template would close that, and is worth considering separately; it isn't in scope here.