From 98e8c27cdf6359b7da57c9a351ba2d5e781aad4e Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 6 Dec 2026 16:15:28 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- tests/test-rtk-hook.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test-rtk-hook.sh b/tests/test-rtk-hook.sh index ae9f096..68b514e 100755 --- a/tests/test-rtk-hook.sh +++ b/tests/test-rtk-hook.sh @@ -18,7 +18,8 @@ fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); } [[ -f "$SRC" ]] || { echo "FAIL: $SRC does not exist"; exit 1; } 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)" trap 'rm -rf "$WORK"' EXIT @@ -105,6 +106,10 @@ else # so rtk passes it through with no output. A later rtk may add one. 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 + # 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 echo "== hooks.json"