3d24925d6e
Plan simplification: dropped the broken middle elif heuristic that had unbalanced shell expression. Kept clean two-step fallback: .template suffix first, bare filename second. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.1 KiB
Bash
33 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -u
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
source "$SCRIPT_DIR/lib/common.sh"
|
|
|
|
FAILURES=0
|
|
assert_eq() {
|
|
if [ "$1" = "$2" ]; then echo "PASS: $3"; else echo "FAIL: $3 (expected '$1', got '$2')"; FAILURES=$((FAILURES + 1)); fi
|
|
}
|
|
|
|
# Test: identical content → exit 0 (no diff)
|
|
tmpdir=$(mktemp -d)
|
|
brain="$tmpdir/brain"
|
|
consumer="$tmpdir/consumer"
|
|
mkdir -p "$brain/project-files" "$consumer"
|
|
echo "same content" > "$brain/project-files/CLAUDE.md.template"
|
|
echo "same content" > "$consumer/CLAUDE.md"
|
|
|
|
BRAIN_ROOT="$brain" bash "$SCRIPT_DIR/extract.sh" --source="$consumer" --file=CLAUDE.md --dry-run >/dev/null 2>&1
|
|
assert_eq "0" "$?" "identical content returns exit 0"
|
|
|
|
# Test: different content → exit non-zero
|
|
echo "consumer different" > "$consumer/CLAUDE.md"
|
|
BRAIN_ROOT="$brain" bash "$SCRIPT_DIR/extract.sh" --source="$consumer" --file=CLAUDE.md --dry-run >/dev/null 2>&1
|
|
result=$?
|
|
[ "$result" -ne 0 ] && assert_eq "0" "0" "different content returns non-zero" || assert_eq "0" "1" "different content returns non-zero"
|
|
|
|
rm -rf "$tmpdir"
|
|
|
|
echo "---"
|
|
echo "Failures: $FAILURES"
|
|
exit $FAILURES
|