test(rtk): cover an already-prefixed command and a missing timeout

Add a real-rtk case: a `rtk git status` payload yields no output and
exit 0, backing the README's claim that running both the plugin hook and
rtk's global hook is harmless. It skips with the other real-rtk cases
when rtk is absent.

Fail with a clear message when timeout(1) is missing instead of aborting
silently under set -e.

Refs: #179

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-06 16:15:28 +00:00
1 parent 96307b2a5e
commit 98e8c27cdf
1 file changed
+6 -1
+6 -1
View File
@@ -18,7 +18,8 @@ fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
[[ -f "$SRC" ]] || { echo "FAIL: $SRC does not exist"; exit 1; } [[ -f "$SRC" ]] || { echo "FAIL: $SRC does not exist"; exit 1; }
REAL_RTK="$(command -v rtk || true)" REAL_RTK="$(command -v rtk || true)"
TIMEOUT="$(command -v timeout)" TIMEOUT="$(command -v timeout || true)"
[[ -n "$TIMEOUT" ]] || { echo "FAIL: timeout(1) is not on PATH; install coreutils to run these tests"; exit 1; }
WORK="$(mktemp -d)" WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT trap 'rm -rf "$WORK"' EXIT
@@ -105,6 +106,10 @@ else
# so rtk passes it through with no output. A later rtk may add one. # so rtk passes it through with no output. A later rtk may add one.
run "$HOOK" "$REAL_PATH" "echo hello" run "$HOOK" "$REAL_PATH" "echo hello"
if [[ $RC -eq 0 && -z "$OUT" ]]; then pass; else fail "echo hello: want no output, got $RC: $OUT"; fi if [[ $RC -eq 0 && -z "$OUT" ]]; then pass; else fail "echo hello: want no output, got $RC: $OUT"; fi
# Backs the README's "running both hooks is harmless": rtk leaves a command
# that already starts with rtk alone, so a second hook adds nothing.
run "$HOOK" "$REAL_PATH" "rtk git status"
if [[ $RC -eq 0 && -z "$OUT" ]]; then pass; else fail "rtk git status: want no output, got $RC: $OUT"; fi
fi fi
echo "== hooks.json" echo "== hooks.json"