Skip to content

docs(test-support): lead with the closure form most tables use#2707

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-2693
Jun 21, 2026
Merged

docs(test-support): lead with the closure form most tables use#2707
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-2693

Conversation

@chet

@chet chet commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Wave 1 of the carbide-test-support integration (#2692).

The module docs led with the fn_path: shorthand, but 710 of 734 macro calls use the run = closure form instead, and the closing guidance pointed at a local struct Case plus assert_outcome pattern that nothing in the tree uses. This leads the examples with run = |...|, keeps the fn: shorthand as an aside, documents the real several-inputs idiom (a local struct used as the row input and destructured in the closure), and scopes assert_outcome to the hand-written-case escape hatch.

Docs only -- the new examples run as doctests (cargo test --doc -p carbide-test-support: 9 pass).

Addresses #2693.

@copy-pr-bot

copy-pr-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 420e6e07-8d01-4655-8cfb-f9cd134e0497

📥 Commits

Reviewing files that changed from the base of the PR and between e927e72 and fe3612c.

📒 Files selected for processing (1)
  • crates/test-support/src/lib.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/test-support/src/lib.rs

Summary by CodeRabbit

  • Documentation
    • Updated documentation for test support macros with clearer examples and improved guidance on testing patterns and handling multiple inputs.

Walkthrough

Documentation in crates/test-support/src/lib.rs is updated for the scenarios! and value_scenarios! macros. The primary examples are revised to use the run = |closure| form, a new section demonstrates multiple inputs per row via a local struct with destructuring, and the shared-convention text is rewritten to center on Outcome, assert_outcome, and the thin macro syntax.

Changes

Macro Documentation: scenarios! and value_scenarios!

Layer / File(s) Summary
scenarios! closure form and fn: shorthand clarification
crates/test-support/src/lib.rs
The grouped-scenarios narrative now directs users to the run = |input| ... closure form; the inline example is updated accordingly, and a note is added explaining that fn: shorthand expands to the same table structure.
value_scenarios! closure form, multi-input pattern, and convention rewrite
crates/test-support/src/lib.rs
The value_scenarios! example is changed to use run = ... closure syntax; a new section demonstrates providing multiple inputs per row via a local row struct and destructuring; the "What's shared" section is reworded to foreground Outcome, assert_outcome, and the macro-as-thin-syntax framing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title precisely identifies the primary change: restructuring documentation to prioritize the closure form (run =) over the shorthand syntax, which aligns with actual codebase usage patterns.
Description check ✅ Passed The description comprehensively explains the rationale and scope of changes: aligning docs with 710 of 734 actual macro calls using closure syntax, correcting misleading guidance, and confirming all doctests pass.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@chet

chet commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai PTAL, thanks!

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

gh pr view 2707 --repo NVIDIA/infra-controller --json title,body,files,additions,deletions

echo "=== DIFF ==="
gh pr diff 2707 --repo NVIDIA/infra-controller

Length of output: 4204



@chet: The change is well-motivated and cleanly executed. Aligning the docs with the dominant usage pattern (710 of 734 call sites) is the right call, and repositioning assert_outcome as a low-level escape hatch rather than a recommended workflow removes genuinely misleading guidance.

One minor editorial nit worth addressing before merge:

crates/test-support/src/lib.rs, line 84 — missing comma after an adverbial phrase opener:

// current
//! For a bare named function the `fn:` shorthand reads a little cleaner --

// suggested
//! For a bare named function, the `fn:` shorthand reads a little cleaner --

Everything else looks solid:

  • The run = |Row { left, right }| ... example is a realistic, idiomatic illustration of the multi-input idiom.
  • Em-dash normalization (--) is consistent with the rest of the file.
  • The fn: shorthand is retained as a natural aside without burying the common path.
  • Doctest imports (carbide_test_support with underscores) are correct.

One question on the "Several inputs per row" doctest: does value_scenarios! impose any trait bounds on the input type (e.g., Debug, Clone)? The Row struct in the example derives neither. If the macro expands to something that needs Debug for failure messages, adding #[derive(Debug)] to the example struct would make the docs more copy-pasteable.

Otherwise, this is a clean, focused improvement. Happy to approve once the comma nit is addressed (or if you prefer to leave it as-is, that's a reasonable call too).

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The module docs taught the `fn_path:` shorthand first, but almost every table in
the tree reaches for the `run =` closure form instead -- 710 of 734 macro calls
use it -- and the closing guidance pointed at a local `struct Case` plus
`assert_outcome` pattern that nothing in the tree actually uses. A reader learned
the rare form and met the common one only by reading other tests.

The docs now lead with `run = |...|`, keep the `fn:` shorthand as the aside it
should be, document the real several-inputs idiom (a local struct used as the row
`input` and destructured in the closure), and scope `assert_outcome` to the
hand-written-case escape hatch it is.

Docs only -- the new examples run as doctests.

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet

chet commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai Thanks for the eyes. Updated -- added the comma after For a bare named function. On the Row bounds: value_scenarios! / check_values only bound the value type (T: PartialEq + Debug); the input type has no bounds (it is just moved into the closure), so the example compiles with Row underived -- kept it minimal on purpose so it does not imply the input needs Debug. PTAL. Resolve if good, thanks!

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# List CodeRabbit's review comments on PR `#2707` to find the comment ID to resolve
gh api graphql \
  -F owner="NVIDIA" \
  -F repo="infra-controller" \
  -F pr=2707 \
  -f query='
query($owner: String!, $repo: String!, $pr: Int!) {
  repository(owner: $owner, name: $repo) {
    pullRequest(number: $pr) {
      reviewThreads(first: 20) {
        nodes {
          id
          isResolved
          comments(first: 1) {
            nodes {
              author { login }
              body
            }
          }
        }
      }
    }
  }
}'

Length of output: 692



@chet: No open review threads remain on the PR — everything has been addressed. The approval has been submitted. Clean, well-reasoned change; good to merge.

(ʘ‿ʘ)ノ🐇

@chet chet marked this pull request as ready for review June 20, 2026 15:12
@chet chet requested a review from a team as a code owner June 20, 2026 15:12
@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 264 6 23 99 6 130
machine-validation-runner 704 34 183 258 35 194
machine_validation 704 34 183 258 35 194
nvmetal-carbide 704 34 183 258 35 194
TOTAL 2382 108 572 879 111 712

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@chet chet merged commit b86b3ab into NVIDIA:main Jun 21, 2026
98 of 100 checks 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.

2 participants