docs(index): add dream + experiment-spec rows, and gate the index
Both skills shipped without an index row. The rows existed — on the feature branches deleted in #22 — and were dropped by the squash-merge that followed a directory reorg: the SKILL.md landed under skills/, the row did not. Nothing errored, the index just under-reported the library to every harness reading it. Adding two rows by hand fixes today and not tomorrow, so the assertion goes in `task check` via bin/check-index, following the same pattern as bin/should-skip-release: a real script with a real test, not untested logic buried in a Taskfile. It checks both directions — a skill with no row, and a row naming a skill that no longer exists. Verified by mutation: deleting the `dream` row turns `task check` red and the report names it. Closes #15 Bump-Type: patch
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
# Tests for bin/check-index.
|
||||
#
|
||||
# The regression these exist for: SKILLS_INDEX.md is maintained by hand, and
|
||||
# two skills (`dream`, `experiment-spec`) shipped without a row — the index
|
||||
# rows lived on feature branches that were squash-merged after a directory
|
||||
# reorg, so the SKILL.md landed and the row did not (#15, #22). Nothing
|
||||
# errored; the index just quietly under-reported the library.
|
||||
|
||||
set -u
|
||||
|
||||
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
SUT="$ROOT/bin/check-index"
|
||||
|
||||
pass=0
|
||||
fail=0
|
||||
WORK=${TMPDIR:-/tmp}/check_index_test.$$
|
||||
|
||||
if [ ! -f "$SUT" ]; then
|
||||
printf 'FAIL: %s does not exist\n' "$SUT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup() { rm -rf "$WORK"; }
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# new_fixture <name> — a checkout with skills/alpha and skills/beta.
|
||||
new_fixture() {
|
||||
_f="$WORK/$1"
|
||||
mkdir -p "$_f/skills/alpha" "$_f/skills/beta"
|
||||
printf -- '---\nname: alpha\ndescription: a\n---\n' > "$_f/skills/alpha/SKILL.md"
|
||||
printf -- '---\nname: beta\ndescription: b\n---\n' > "$_f/skills/beta/SKILL.md"
|
||||
printf '%s' "$_f"
|
||||
}
|
||||
|
||||
index() {
|
||||
_dir=$1; shift
|
||||
printf '# Engineering Skills Index\n\n| Skill | Description | Use when |\n|---|---|---|\n' > "$_dir/SKILLS_INDEX.md"
|
||||
for _n in "$@"; do
|
||||
printf '| `%s` | desc | when |\n' "$_n" >> "$_dir/SKILLS_INDEX.md"
|
||||
done
|
||||
}
|
||||
|
||||
# expect <0|1> <label> <fixture> [grep-for]
|
||||
expect() {
|
||||
_want=$1; _label=$2; _fx=$3; _needle=${4:-}
|
||||
_out=$(sh "$SUT" "$_fx" 2>&1); _rc=$?
|
||||
if [ "$_rc" -ne "$_want" ]; then
|
||||
fail=$((fail + 1)); printf ' FAIL %s (want rc=%s got %s)\n%s\n' "$_label" "$_want" "$_rc" "$_out"; return
|
||||
fi
|
||||
if [ -n "$_needle" ] && ! printf '%s' "$_out" | grep -q "$_needle"; then
|
||||
fail=$((fail + 1)); printf ' FAIL %s (rc ok, but report never names %s)\n%s\n' "$_label" "$_needle" "$_out"; return
|
||||
fi
|
||||
pass=$((pass + 1)); printf ' ok %s\n' "$_label"
|
||||
}
|
||||
|
||||
fx=$(new_fixture complete); index "$fx" alpha beta
|
||||
expect 0 'every skill has a row' "$fx"
|
||||
|
||||
fx=$(new_fixture missing); index "$fx" alpha
|
||||
expect 1 'a skill with no row is reported' "$fx" beta
|
||||
|
||||
fx=$(new_fixture stale); index "$fx" alpha beta gamma
|
||||
expect 1 'a row for a skill that does not exist is reported' "$fx" gamma
|
||||
|
||||
fx=$(new_fixture noindex)
|
||||
expect 1 'a missing index is reported' "$fx" SKILLS_INDEX.md
|
||||
|
||||
printf '\ncheck_index: %d passed, %d failed\n' "$pass" "$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
Reference in New Issue
Block a user