#!/usr/bin/env bash # Everything that can be checked from this machine, in one command. # # scripts/test.sh static checks, Python unit tests, CLI tests # scripts/test.sh --windows [host] ...and the PowerShell suite on a Windows host # over SSH (default host: winbox) # # Nothing here touches the real install. The CLI tests run in a sandbox with its # own HOME, CM_ROOT and CLAUDE_CONFIG_DIR and a file-only vault (tests/lib.sh), # and the Windows suite points USERPROFILE at a temp folder (tests/windows/run.ps1). set -uo pipefail cd "$(dirname "$0")/.." windows=0 host=winbox while [ $# -gt 0 ]; do case "$1" in --windows) windows=1 if [ $# -gt 1 ] && [ "${2#-}" = "$2" ]; then host="$2"; shift; fi ;; -h|--help) sed -n '2,11p' "$0"; exit 0 ;; *) echo "unknown option '$1'" >&2; exit 2 ;; esac shift done failed='' step() { local name="$1"; shift "$@" || failed="$failed $name" } printf '== static\n' step static bash tests/static.sh printf '\n== python\n' step python env PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests/python -p 'test_*.py' printf '\n== cli\n' for t in tests/cli/test_*.sh; do step "cli/$(basename "$t" .sh)" bash "$t" done if [ "$windows" -eq 1 ]; then printf '\n== windows (%s)\n' "$host" step windows bash tests/windows/run-remote.sh "$host" fi printf '\n' if [ -z "$failed" ]; then echo 'all passed' else echo "FAILED:$failed" exit 1 fi