From a4a4cbbe91392a5b417294841f143ab79d120f9e Mon Sep 17 00:00:00 2001 From: EnRaiha <15997552+EnRaiha@users.noreply.github.com> Date: Sat, 5 Sep 2026 14:34:41 +0800 Subject: [PATCH] ci(calvin): handle indented #[cfg(test)] and improve error message 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 #290 extended proposal. Without this, every test-only helper added under a scanned Calvin path trips the gate. Fixes #290 --- scripts/ci/check_calvin_determinism.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/check_calvin_determinism.sh b/scripts/ci/check_calvin_determinism.sh index 37ff0d376..37420fd8b 100755 --- a/scripts/ci/check_calvin_determinism.sh +++ b/scripts/ci/check_calvin_determinism.sh @@ -84,9 +84,9 @@ for rel in "${scan_paths[@]}"; do esac # Skip if inside a #[cfg(test)] mod tests { ... } block. - last_cfg=$(awk -v n="$lineno" 'NR<=n && /^#\[cfg\(test\)\]/ {x=NR} END{print x+0}' "$file") + last_cfg=$(awk -v n="$lineno" 'NR<=n && /^[[:space:]]*#\[cfg\(test\)\]/ {x=NR} END{print x+0}' "$file") if [ "$last_cfg" -gt 0 ]; then - close_after=$(awk -v a="$last_cfg" -v b="$lineno" 'NR>a && NRa && NR