#!/bin/sh # Tests for bin/doctor. # # Every case here is a real state this fleet was found in on 2026-08-23, and # every one of them was SILENT — nothing errored, git status was clean, the # harness simply ran with the wrong skills or none at all. The point of doctor # is that none of these can be silent again, so each fixture asserts both a # non-zero exit AND that the report names the fault. # # Fixtures drive doctor through $HOME and $DOCTOR_CHECKOUT, so no test touches # the real host. set -u ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) DOCTOR="$ROOT/bin/doctor" pass=0 fail=0 WORK=${TMPDIR:-/tmp}/doctor_test.$$ if [ ! -f "$DOCTOR" ]; then printf 'FAIL: %s does not exist\n' "$DOCTOR" exit 1 fi cleanup() { rm -rf "$WORK"; } trap cleanup EXIT INT TERM # new_fixture — builds $WORK//{ck,home} with a 2-skill checkout # and an empty fake HOME. Echoes the fixture root. new_fixture() { _f="$WORK/$1" mkdir -p "$_f/ck/skills/alpha" "$_f/ck/skills/beta" "$_f/home" printf -- '---\nname: alpha\ndescription: a\n---\n' > "$_f/ck/skills/alpha/SKILL.md" printf -- '---\nname: beta\ndescription: b\n---\n' > "$_f/ck/skills/beta/SKILL.md" printf '%s' "$_f" } # wire_clean — the correct wiring: one canonical link, harnesses # pointing at it. wire_clean() { mkdir -p "$1/home/.agents" "$1/home/.config/crush" "$1/home/.config/opencode" ln -sfn "$1/ck/skills" "$1/home/.agents/skills" ln -sfn "$1/home/.agents/skills" "$1/home/.config/crush/skills" ln -sfn "$1/home/.agents/skills" "$1/home/.config/opencode/skills" } # assert_fails