Files
splinter/tests/test_interview.sh
lotherk 6d9c74e3b1 cli: --interview needs no transport, and a test
check_usage demanded a transport before the ack/interview paths ran, so
'--no-config --interview' failed with 'no transport' even though neither
path runs a model. Exempt the ack and interview modes.

tests/test_interview.sh pipes six answers through the real binary,
checks the English catalogue prompts, the skipped marker and the written
profile. README notes that the questions follow the locale.
2026-11-10 07:46:28 +00:00

35 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# splinter -- the first-run interview from the terminal.
#
# No transport is needed; the questions come from the catalogue (English here),
# and the answers are written to profile/<user>.md. The six answers also prove
# that a skipped question (the empty line) is recorded as such.
set -u
cd "$(dirname "$0")/.." || exit 1
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-iv-XXXXXX") || exit 1
cleanup() { rm -rf "$D"; }
trap cleanup EXIT
fails=0
check() { # $1 = description, $2.. = command
d=$1; shift
if "$@"; then :; else echo "FAIL $d"; fails=$((fails + 1)); fi
}
out=$(printf 'english\nabout me\nC99\n\nno commits\n/home/carol\n' | \
HOME="$D" SPLINTER_LOCALE=en ./splinter --no-config \
--session "$D/sess" --interview 2>&1)
check "the interview needs no transport" test $? -eq 0
echo "$out" | grep -q 'First conversation'
check "the questions are in the process language" test $? -eq 0
echo "$out" | grep -q 'Which language should I speak'
check "the language question is English" test $? -eq 0
prof=$(ls "$D/sess/profile/"*.md 2>/dev/null | head -1)
check "the profile was written" test -n "$prof"
check "the first answer is in the profile" grep -q 'english' "$prof"
check "the skipped question is not a lie" grep -q '(not answered)' "$prof"
check "the last section is in the profile" grep -q '## paths' "$prof"
if [ "$fails" -eq 0 ]; then echo "test_interview: ok"; exit 0; fi
exit 1