Files
codex-crew/tests/test-run.sh
T
admin 0cfec6880c fix: pass codex flags through in the stdin-prompt branch
Follow-up to the previous fix: the stdin branch dropped "$@", so
options like -s read-only silently never reached codex. Stub now
records argv and tests assert flags + stdin prompt arrive together;
verified live (-s read-only => codex reports READONLY).
2026-07-07 16:58:04 +05:00

35 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
RUN=$HERE/../scripts/codex-run.sh
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
# 1. happy path -> status ok, thread_id captured, exit 0
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/ok" exec "hello"
[[ $(cat "$TMP/ok/status") == ok ]]
[[ $(cat "$TMP/ok/thread_id") == test-thread-123 ]]
[[ $(cat "$TMP/ok/last.md") == "stub answer|args="*"hello|" ]]
# 2. stall -> watchdog kills, status stalled, exit nonzero
if CODEX_BIN=$HERE/stub-hang/codex CODEX_STALL_TIMEOUT=4 CODEX_WATCH_INTERVAL=2 \
"$RUN" "$TMP/hang" exec "hello"; then
echo "FAIL: stall run must exit nonzero"; exit 1
fi
[[ $(cat "$TMP/hang/status") == stalled ]]
[[ $(cat "$TMP/hang/thread_id") == hang-thread-456 ]]
# 3. prompt.md via stdin path
mkdir -p "$TMP/stdin"; echo "prompt from file" > "$TMP/stdin/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/stdin" exec
[[ $(cat "$TMP/stdin/status") == ok ]]
[[ $(cat "$TMP/stdin/last.md") == "stub answer|args="*" -|prompt from file" ]]
# 4. prompt.md + codex flags -> stdin still delivered (regression: options ate the prompt)
mkdir -p "$TMP/flags"; echo "prompt with flags" > "$TMP/flags/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/flags" exec -s read-only
[[ $(cat "$TMP/flags/status") == ok ]]
[[ $(cat "$TMP/flags/last.md") == "stub answer|args="*"-s read-only -|prompt with flags" ]]
echo "ALL PASS"