Files
My-Brain-Is-Full-Crew/tests/run.sh
nunziati 8d71875c2b fix: address Copilot review feedback on PR #32
- tests/run.sh: check source return code, report failures
- tests/regression/run.sh: use mktemp + trap cleanup instead of fixed /tmp paths
- tests/regression/run.sh: include .mcp.json in regression comparison
- tests/regression/take-snapshot.sh: use --platform flag instead of stale scripted input
- adapters/opencode/templates/plugin-stub.js.tmpl: include stdout in hook block error message
2026-04-10 20:26:50 +00:00

44 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# =============================================================================
# tests/run.sh — Bash test runner
# =============================================================================
# Discovers all *.test.sh files under tests/ and runs each function whose name
# starts with "test_". Reports pass/fail counts and exits non-zero on failure.
# =============================================================================
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PASS=0
FAIL=0
FAILED_TESTS=()
while IFS= read -r test_file; do
echo "── $(basename "$test_file") ──────────────────────"
# Source the test file to get its functions
if ! source "$test_file"; then
echo " ✗ FAILED TO SOURCE: $test_file"
FAIL=$((FAIL + 1))
FAILED_TESTS+=("SOURCE:$(basename "$test_file")")
continue
fi
# Run every function starting with test_
for fn in $(declare -F | awk '{print $3}' | grep '^test_'); do
if (set -e; "$fn") 2>&1 | sed 's/^/ /'; then
echo "$fn"
PASS=$((PASS + 1))
else
echo "$fn"
FAIL=$((FAIL + 1))
FAILED_TESTS+=("$fn")
fi
unset -f "$fn"
done
done < <(find "$SCRIPT_DIR" -name '*.test.sh' | sort)
echo ""
echo "==========================="
echo " Passed: $PASS"
echo " Failed: $FAIL"
[[ $FAIL -gt 0 ]] && { echo " Failed tests: ${FAILED_TESTS[*]}"; exit 1; }
exit 0