Skip to content

docs(adrs): clarify rule C placement, src/testing and the test_ prefix in the test-support ADR - #2782

Merged
josecelano merged 1 commit into
torrust:developfrom
josecelano-bot:docs/adr-test-support-placement
Nov 9, 2026
Merged

josecelano merged 1 commit into
torrust:developfrom
josecelano-bot:docs/adr-test-support-placement

Conversation

@josecelano-bot

Copy link
Copy Markdown
Contributor

Related to #2637

Clarifies ADR 20261021190318 (share workspace test support through testing features) with one dated in-place amendment, as the earlier amendments of the same ADR do. Documentation only. This is the follow-up recorded in the lessons.md of the #2637 spec; it has no issue of its own.

Summary

The amendment records three answers the maintainer confirmed on 2026-11-09 to the questions raised in the #2637 review of axum-rest-api-server:

  1. Rule C placement. A helper used only inside one crate may live at the crate root as a private #[cfg(test)] mod with an inner #![cfg(test)] in its file (as axum-rest-api-server's src/test_support.rs does). It needs no testing feature and does not go under src/testing/.
  2. What src/testing/ holds. Only test support that other crates use, compiled behind the package's testing feature (rules A and D).
  3. Naming. A file that contains only test code outside a #[cfg(test)] mod tests carries the prefix test_. tracker-core's test_helpers.rs and whitelist/test_helpers.rs already follow it, so nothing moves.

The decision of the ADR stands; no rule is changed. The confirmation is the maintainer's reply in the #2637 session; his earlier remarks (2026-10-28) are in the #2637 spec's progress log and plans.

Validation

The pre-commit script (including linter all) and the pre-push script passed. The reference to the #2637 lessons is plain text, so the PR does not depend on the archive PR #2781 merging first.

🤖 Generated with Claude Code

…x in the test-support ADR

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@josecelano josecelano self-assigned this Nov 9, 2026
@josecelano
josecelano requested review from da2ce7 and a balanced review from Copilot November 9, 2026 12:39
@josecelano

Copy link
Copy Markdown
Member

ACK 95529ec

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 95529ec4faea49f0739f451803cea164a83afe9c. Recomputed from the bytes at this head, against the merge base 314721d8b; git merge-tree against develop 28d6d0091 merges cleanly, and the only path differing from develop is the ADR, whose blob is the head's.

Process: an in-place amendment of a root ADR, governed by create-adr and write-markdown-docs, with commit-changes and open-pull-request for the commit and the description. It has the shape of the two earlier amendments of this ADR: a dated blockquote at the top, the ADR as the only file touched, the index row and frontmatter left alone.

The change against its claim: one file, 14 added lines, one amendment with three items, as the title and description say. Item 1 holds: lib.rs:158-159 of axum-rest-api-server declares a private #[cfg(test)] mod test_support; and that file opens with #![cfg(test)]. Item 2 holds: src/testing/ exists in three packages, each gated by the testing feature, and the health check package's tests import all three. Item 3 names real files, but its wording does not fit them or the tree (F1, F2).

Consistency: the ADR's 20 links and anchors resolve and none is in the added lines, so the plain-text reference to the #2637 lessons.md survives that folder's archive move. Nothing moves or is renamed, the dictionary is unchanged, and every new word in the added lines is ordinary English or already used across the tree.

Hygiene: one commit, 95529ec4f, Conventional subject, no issue bracket since the change has no issue of its own, no body, author = committer, one attribution footer naming a model, which no rule in the tree forbids. git diff --check is clean, the commit-id check prints nothing, and the closing-keyword pattern matches nothing in the title, description or message.

Findings: three inline, F1 and F2 Minor, F3 Nit. None blocks: the rule's intent is recoverable from its examples, no placement or gate the amendment states is wrong, and one more dated amendment can tighten each.

Checked, no finding: the amendment date against the commit; rule C's text and the placement table against item 1; item 2's citation of rules A and D against the routes plan, with D's one shared mock generated on its trait, which the item does not contradict; the whitelist/test_helpers.rs path and the crate-root position of test_helpers.rs; the description's references to the progress log and plans.

Checks

On the loop's compute node at this head, against the merge base 314721d8b (receipt server-gates-kranich-556): the repository's pre-commit gate exit 0 (70 s), clippy-allow-reasons against the base exit 0, and the tree left clean; linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 15 errors / 4 warnings at this head and at the base re-measured, so none is new. git merge-tree against develop 86c7ed2a5 (which advanced after the lane's measurement) is also clean. The forge reports this head as mergeable. GitHub checks at this head at posting time: "Docs Lint: completed/success". At posting, develop is 86c7ed2a5.

> `testing` feature (rules A and D). Test code used only inside the crate is rule C and does not go there.
> 3. **Naming.** A file that contains only test code outside a `#[cfg(test)] mod tests` carries the prefix
> `test_` (`test_support.rs`, and `tracker-core`'s `test_helpers.rs` and `whitelist/test_helpers.rs`,
> which already follow it and need no move).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Minor][F1] The test_ rule lists two conforming tracker-core files and omits peer_tests.rs, which does not conform

packages/tracker-core/src/peer_tests.rs is declared #[cfg(test)] mod peer_tests; (lib.rs:131-132) and opens with #![cfg(test)], so it is a file of test code only, and it has no test_ prefix. Under src/ the workspace has exactly four whole-file test-only modules; this is the one without the prefix, in the same crate item 3 reports as needing no move, and the description's "so nothing moves" carries the same gap into the merge commit. Either name it as the remaining rename, or say why a *_tests.rs sidecar falls outside the rule.

> placed under `src/testing/`.
> 2. **What `src/testing/` holds.** Only test support that other crates use, compiled behind the package's
> `testing` feature (rules A and D). Test code used only inside the crate is rule C and does not go there.
> 3. **Naming.** A file that contains only test code outside a `#[cfg(test)] mod tests` carries the prefix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Minor][F2] Item 3's predicate does not describe the files it cites, and read literally it reaches files no one means to rename

Both tracker-core examples are one #[cfg(test)] pub mod tests { ... } block (test_helpers.rs:4-5, whitelist/test_helpers.rs:7-8), so their code is inside such a module and only test_support.rs fits "outside a #[cfg(test)] mod tests". The same words reach the six files of the three src/testing/ trees, which item 2 describes as holding test support, and the 102 unprefixed Rust files among the 103 in tests/ directories. The ADR had no naming rule before, so this sentence alone sets the rule's scope: say something like "a file under src/ whose whole content is compiled only for tests", and state whether src/testing/ and tests/ are outside it.

>
> **Amendment of 2026-11-09 (follow-up of #2637).** The decision stands. Rule C and rule A are clarified
> with the answers the maintainer confirmed on 2026-11-09 to the questions that came up in the #2637
> review of `axum-rest-api-server` (the record is the `lessons.md` of the #2637 spec):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Nit][F3] The record the amendment names holds the questions, not the answers

The follow-up row of lessons.md lists these points as still to decide and has no entry for 2026-11-09; the 2026-10-28 answers are in the progress log of the #2637 ISSUE.md and in test-refactor-plans/v1-routes-tests.md, as the description itself says. Point at those too, or say that lessons.md records the questions.

@da2ce7

da2ce7 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

ACK 95529ec — the three amendment items recomputed against the tree at this head, with the ADR's links and the merge against develop verified

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for this documentation-only amendment clarifying test-support conventions.

No open issues 🎉

What changed in this PR

This documentation-only PR adds a dated amendment to the test-support ADR, recording clarifications from #2637 without changing the existing decision.

Changes:

  • Clarifies placement and test gating for crate-local rule C helpers.
  • Reserves src/testing/ for cross-crate support behind the testing feature.
  • Documents the test_ filename prefix for test-only files outside a #[cfg(test)] mod tests.
File Description
docs/​adrs/​20261021190318_share_workspace_test_support_through_testing_features.md Adds the 2026-11-09 amendment clarifying helper placement, shared support, and naming.

Review effort: Balanced

@josecelano

Copy link
Copy Markdown
Member

ACK 95529ec

@josecelano
josecelano merged commit f9431e5 into torrust:develop Nov 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants