Skip to content

ci(calvin): handle indented #[cfg(test)] and improve error message (#290) - #291

Closed
EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:fix/calvin-gate-indented-cfg
Closed

ci(calvin): handle indented #[cfg(test)] and improve error message (#290)#291
EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:fix/calvin-gate-indented-cfg

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

check_calvin_determinism.sh anchored its #[cfg(test)] skip on ^#\[cfg(test)\] (no leading whitespace). An indented #[cfg(test)] inside an impl — e.g. sub_plan.rs:build_dummy_task — was never recognised, so Instant::now was flagged even though the helper is test-only. Unindenting the attribute to column 0 breaks cargo fmt (which keeps #[cfg(test)] indented inside impl), so the gate must handle indented form itself.

Fix

  • Change skip anchor to ^[[:space:]]*#\[cfg(test)\] (and same for closing }) so indented test helpers are skipped like top-level mod tests.
  • Improve failure message to tell contributors the two valid fixes: unindent to column 0 as per cargo fmt (for top-level mods where fmt keeps it at 0) or add // no-determinism: <reason> on the same/preceding line. This matches the extended proposal in Calvin determinism gate misses indented #[cfg(test)] — confusing error for contributors #290.

Verification

bash scripts/ci/check_calvin_determinism.sh  # → OK
cargo fmt --all -- --check  # → 0

Fixes #290.

Copilot AI lite review requested due to automatic review settings September 5, 2026 06:34

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Gate previously anchored on ^#\[cfg(test)\] (no leading space), so
an indented '    #[cfg(test)]' inside an impl was never recognised as
a skip and flagged Instant::now even though helper is test-only.
Change anchor to ^[[:space:]]*#\[cfg(test)\] (and same for closing
brace) so indented test helpers are skipped like top-level mods.

Also improve failure message to tell contributors to unindent the
#[cfg(...)] to column 0 as per cargo fmt (or add // no-determinism
marker), per NodeDB-Lab#290 extended proposal. Without this, every test-only
helper added under a scanned Calvin path trips the gate.

Fixes NodeDB-Lab#290
@EnRaiha
EnRaiha force-pushed the fix/calvin-gate-indented-cfg branch from dd9cd8c to a4a4cbb Compare September 5, 2026 06:37
@EnRaiha EnRaiha closed this Sep 6, 2026
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.

Calvin determinism gate misses indented #[cfg(test)] — confusing error for contributors

2 participants