Files
claude-code/automation/test-scripts.sh
OpenCode Test de89f3066c Add /diff and /template commands
- /diff command to compare config with backups
  - Shows added/removed/changed files
  - JSON-aware comparison for config files
  - List available backups
- /template command for session templates
  - Built-in templates: daily-standup, code-review, troubleshoot, deploy
  - Each template includes checklist, initial commands, prompt
  - Create custom templates interactively or non-interactively
- Updated shell completions with 21 aliases total
- Test suite now covers 29 tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 19:06:14 -08:00

189 lines
5.0 KiB
Bash
Executable File

#!/bin/bash
# Test automation scripts
# Run: ./test-scripts.sh
set -euo pipefail
CLAUDE_DIR="${HOME}/.claude"
AUTOMATION_DIR="${CLAUDE_DIR}/automation"
SKILLS_DIR="${CLAUDE_DIR}/skills"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
PASS=0
FAIL=0
pass() { echo -e "${GREEN}${NC} $1"; PASS=$((PASS + 1)); }
fail() { echo -e "${RED}${NC} $1"; FAIL=$((FAIL + 1)); }
skip() { echo -e "${YELLOW}${NC} $1 (skipped)"; }
echo "🧪 Testing Claude Code Scripts"
echo ""
# Test 1: validate-setup.sh
echo "=== Automation Scripts ==="
if "${AUTOMATION_DIR}/validate-setup.sh" > /dev/null 2>&1; then
pass "validate-setup.sh runs successfully"
else
fail "validate-setup.sh failed"
fi
# Test 2: quick-status.sh (may fail without kubectl)
# Skip in automated testing - requires live connections
skip "quick-status.sh (requires live connections)"
# Test 3: memory-add.py (test syntax only)
if python3 -m py_compile "${AUTOMATION_DIR}/memory-add.py" 2>/dev/null; then
pass "memory-add.py syntax valid"
else
fail "memory-add.py syntax error"
fi
# Test 4: memory-list.py (test syntax only)
if python3 -m py_compile "${AUTOMATION_DIR}/memory-list.py" 2>/dev/null; then
pass "memory-list.py syntax valid"
else
fail "memory-list.py syntax error"
fi
# Test 5: usage_report.py (test syntax only)
if python3 -m py_compile "${SKILLS_DIR}/usage/scripts/usage_report.py" 2>/dev/null; then
pass "usage_report.py syntax valid"
else
fail "usage_report.py syntax error"
fi
# Test 6: search.py
if python3 -m py_compile "${AUTOMATION_DIR}/search.py" 2>/dev/null; then
pass "search.py syntax valid"
else
fail "search.py syntax error"
fi
# Test 7: history-browser.py
if python3 -m py_compile "${AUTOMATION_DIR}/history-browser.py" 2>/dev/null; then
pass "history-browser.py syntax valid"
else
fail "history-browser.py syntax error"
fi
# Test 8: log-viewer.py
if python3 -m py_compile "${AUTOMATION_DIR}/log-viewer.py" 2>/dev/null; then
pass "log-viewer.py syntax valid"
else
fail "log-viewer.py syntax error"
fi
# Test 9: session-export.py
if python3 -m py_compile "${AUTOMATION_DIR}/session-export.py" 2>/dev/null; then
pass "session-export.py syntax valid"
else
fail "session-export.py syntax error"
fi
# Test 10: workflow-info.py
if python3 -m py_compile "${AUTOMATION_DIR}/workflow-info.py" 2>/dev/null; then
pass "workflow-info.py syntax valid"
else
fail "workflow-info.py syntax error"
fi
# Test 11: skill-info.py
if python3 -m py_compile "${AUTOMATION_DIR}/skill-info.py" 2>/dev/null; then
pass "skill-info.py syntax valid"
else
fail "skill-info.py syntax error"
fi
# Test 12: agent-info.py
if python3 -m py_compile "${AUTOMATION_DIR}/agent-info.py" 2>/dev/null; then
pass "agent-info.py syntax valid"
else
fail "agent-info.py syntax error"
fi
# Test 13: config-diff.py
if python3 -m py_compile "${AUTOMATION_DIR}/config-diff.py" 2>/dev/null; then
pass "config-diff.py syntax valid"
else
fail "config-diff.py syntax error"
fi
# Test 14: session-template.py
if python3 -m py_compile "${AUTOMATION_DIR}/session-template.py" 2>/dev/null; then
pass "session-template.py syntax valid"
else
fail "session-template.py syntax error"
fi
echo ""
echo "=== Skill Scripts ==="
# Test Gmail scripts (syntax only - need credentials to run)
for script in check_unread.py check_urgent.py search.py; do
if python3 -m py_compile "${SKILLS_DIR}/gmail/scripts/${script}" 2>/dev/null; then
pass "gmail/${script} syntax valid"
else
fail "gmail/${script} syntax error"
fi
done
# Test GCal scripts
for script in agenda.py next_event.py; do
if python3 -m py_compile "${SKILLS_DIR}/gcal/scripts/${script}" 2>/dev/null; then
pass "gcal/${script} syntax valid"
else
fail "gcal/${script} syntax error"
fi
done
# Test bash scripts (syntax check with bash -n)
echo ""
echo "=== Bash Scripts ==="
for script in quick-status.sh health-check.sh; do
script_path=$(find "${CLAUDE_DIR}" -name "${script}" -type f | head -1)
if [[ -n "${script_path}" ]]; then
if bash -n "${script_path}" 2>/dev/null; then
pass "${script} syntax valid"
else
fail "${script} syntax error"
fi
fi
done
# Test k8s quick-status
if bash -n "${SKILLS_DIR}/k8s-quick-status/scripts/quick-status.sh" 2>/dev/null; then
pass "k8s/quick-status.sh syntax valid"
else
fail "k8s/quick-status.sh syntax error"
fi
# Test automation bash scripts
for script in install.sh daily-maintenance.sh backup.sh restore.sh clean.sh debug.sh mcp-status.sh upgrade.sh; do
if [[ -f "${AUTOMATION_DIR}/${script}" ]]; then
if bash -n "${AUTOMATION_DIR}/${script}" 2>/dev/null; then
pass "${script} syntax valid"
else
fail "${script} syntax error"
fi
fi
done
echo ""
echo "=== Summary ==="
echo -e "Passed: ${GREEN}${PASS}${NC}"
echo -e "Failed: ${RED}${FAIL}${NC}"
if [[ ${FAIL} -eq 0 ]]; then
echo -e "\n${GREEN}All tests passed!${NC}"
exit 0
else
echo -e "\n${RED}${FAIL} test(s) failed${NC}"
exit 1
fi