Skip to content

test(doc-templates): replace rotted doc line-number citations and stale template examples - #4012

Open
worktrunk-bot wants to merge 1 commit into
mainfrom
nightly/clean-33950159892
Open

test(doc-templates): replace rotted doc line-number citations and stale template examples#4012
worktrunk-bot wants to merge 1 commit into
mainfrom
nightly/clean-33950159892

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

tests/integration_tests/doc_templates.rs exists 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 its line N citations 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. Because expand_template substitutes whatever names the caller puts in its HashMap, 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 main at 51fd3b2
Test Cited What is actually there now
test_doc_hash_port_repo_branch_concatenation hook.md line 176 the -v resolved-variables paragraph
test_doc_example_docker_postgres tips-patterns.md lines 75-84 tail of an auto-generated wt list block, then the ## Database per worktree heading
test_doc_example_database_url tips-patterns.md lines 96-101 the [[post-start]] docker block
test_doc_example_dev_server hook.md lines 168-170 "Undefined variables error — use conditionals…"
test_doc_example_worktree_path_sanitize tips-patterns.md line 217 the ## LLM branch summaries heading

Each 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_variables asserted {{ worktree }}, while the hook.md "Template variables" table it names documents worktree_path. worktree is row 2 of DEPRECATED_VARS. Now worktree_path.

  • test_doc_example_worktree_path_sanitize tested {{ main_worktree }}.{{ branch | sanitize }}, and quoted a doc line (worktree-path = "{{ branch | sanitize }}") that matches neither the citation nor the template. main_worktree is also in DEPRECATED_VARS. The docs' actual bare-repo example is worktree-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-vars step and referencing them as {{ vars.container }} / {{ vars.port }}, so the docker run shape the test asserted on is gone. The two expressions it was really exercising still exist, in set-vars — so test_doc_example_docker_postgres is renamed test_doc_example_database_vars and points there. test_doc_example_database_url likewise: the documented db_url ends in {{ branch | sanitize_db }}, not {{ repo }}.

Verification

cargo test --test integration doc_templates — 16 passed. cargo fmt --check and cargo clippy --tests -- -D warnings clean.

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's starts_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.

…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.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant