Tests, licence, and the tooling to keep the repo consistent
A test suite with no dependencies beyond bash and the Python standard library, run by one command: scripts/test.sh (or: make test) scripts/test.sh --windows [host] adds the PowerShell suite over SSH - tests/static.sh: script syntax, JSON validity, VERSION against the widget manifest and CHANGELOG, providers.json against the kinds, probes and checks the code implements (and ids that would shadow a command), qmllint and shellcheck when installed. - tests/python: unit tests for cm-json.py - providers and the column contract bash depends on, the original three scaffolds byte for byte, every catalogue parser and the cache, session scan/dismiss/repair, rename, defaults, health, the cost guard. - tests/cli: the CLI in a sandbox with its own HOME, CM_ROOT, CLAUDE_CONFIG_DIR and a file-only vault, against fake Ollama, LM Studio, keyed-gateway and proxy servers - preflight, presets, models, doctor, a real switch, sessions, and the key helper under a rename race. - tests/windows: the same idea on a Windows host, with USERPROFILE pointed at a temp folder so the real install is never touched. Also: MIT licence, CHANGELOG.md reconstructed from history, .editorconfig and .gitattributes pinning LF everywhere (what the tree already is), and scripts/bump-version.sh, since the version lives in two files and drifted once before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Set the version everywhere it is recorded: VERSION (read by both CLIs and
|
||||
# stamped into health.json) and the bar widget's manifest. tests/static.sh
|
||||
# fails when the two disagree - they drifted apart once already (1.8.0 against
|
||||
# 1.9.3) with nothing to notice.
|
||||
#
|
||||
# scripts/bump-version.sh 1.13.0
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
new="${1:-}"
|
||||
if ! [[ "$new" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "usage: scripts/bump-version.sh <major.minor.patch> (now $(cat VERSION))" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "$new" > VERSION
|
||||
python3 - "$new" <<'PY'
|
||||
import json, re, sys
|
||||
path = "omarchy/smoido.claude-mode/manifest.json"
|
||||
text = open(path, encoding="utf-8").read()
|
||||
# A targeted substitution rather than a json.dump, so the file's own layout
|
||||
# (key order, spacing, the kinds array on one line) is left alone.
|
||||
new = re.sub(r'("version"\s*:\s*")[^"]*(")', lambda m: m.group(1) + sys.argv[1] + m.group(2), text, count=1)
|
||||
json.loads(new)
|
||||
open(path, "w", encoding="utf-8").write(new)
|
||||
PY
|
||||
echo "version $new - add a CHANGELOG.md entry for it"
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user