Files
splinter/tests/test_delegate_cli.sh
T
lotherkandClaude Sonnet 5.5 478e2ec663 planner, tmux: rewrite with real JSON, validation and tests
planner: v0.2, state in plan_task_*.json via libmcp, atomic replace, refused states.
tmux: v0.3, in-process capture-pane diff, no watcher helper, tmux_ask/read/capture.
tests: test_tmux added, test_delegate_cli no longer hangs without a tty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 17:13:20 +00:00

46 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# splinter -- one named delegate, no model: the diagnostic path.
#
# This is how a failing delegate is inspected: the observation carries the
# child's exit status, its own error text and the job line. The fake ssh is
# the far side, so no network and no account is involved.
set -u
# splinter reads a piped stdin as context; without a terminal that waits for EOF.
exec </dev/null
cd "$(dirname "$0")/.." || exit 1
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-delcli-XXXXXX") || exit 1
cleanup() { rm -rf "$D"; }
trap cleanup EXIT
fails=0
check() { if "$@"; then :; else echo "FAIL $*"; fails=$((fails + 1)); fi; }
mkdir -p "$D/home"
printf '#!/bin/sh\necho "antwort von der cli"\n' > "$D/ssh"
chmod +x "$D/ssh"
cat > "$D/conf" <<'EOF'
delegate = fake | ein fake | host=fakehost | endpoint=http://example/v1 | model=m | tags=x
EOF
out=$(PATH="$D:$PATH" HOME="$D/home" ./splinter --config "$D/conf" \
--delegate fake -p "hallo" 2>&1)
echo "$out" | grep -q -F '[delegate fake'
check test $? -eq 0
echo "$out" | grep -q 'antwort von der cli'
check test $? -eq 0
# the tool reports an unknown delegate instead of guessing
out=$(PATH="$D:$PATH" HOME="$D/home" ./splinter --config "$D/conf" \
--delegate nosuch -p "hallo" 2>&1)
echo "$out" | grep -q 'no delegate matches'
check test $? -eq 0
# the task is required
PATH="$D:$PATH" HOME="$D/home" ./splinter --config "$D/conf" \
--delegate fake >/dev/null 2>"$D/err"
check test $? -eq 2
grep -q 'needs -p TEXT' "$D/err"
check test $? -eq 0
if [ "$fails" -eq 0 ]; then echo "test_delegate_cli: ok"; exit 0; fi
exit 1