Files
llm-intelligence/scripts/review/blocker_switch_guard_test.sh
2026-05-29 18:48:48 +08:00

32 lines
951 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$ROOT_DIR"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
BAD_FILE="$TMP_DIR/review-switch.txt"
cat > "$BAD_FILE" <<'EOF'
### 2026-05-29 15:10afternoon-review cron
- xfyun-live smoke FAIL 替换 sensenova-live
EOF
set +e
bash scripts/review/blocker_switch_guard.sh "$BAD_FILE" >/tmp/blocker_switch_bad.out 2>&1
BAD_RC=$?
set -e
[[ "$BAD_RC" -ne 0 ]]
grep -q 'missing blocker switch freshness hint' /tmp/blocker_switch_bad.out
GOOD_FILE="$TMP_DIR/review-switch-good.txt"
cat > "$GOOD_FILE" <<'EOF'
### 2026-05-29 15:10afternoon-review cron
- xfyun-live smoke FAIL 替换 sensenova-live
- freshness_hint=same-day-blocker-switch old=sensenova-live new=xfyun-live
EOF
bash scripts/review/blocker_switch_guard.sh "$GOOD_FILE" >/tmp/blocker_switch_good.out 2>&1
grep -q 'BLOCKER_SWITCH_GUARD: PASS' /tmp/blocker_switch_good.out