feat: codex-run.sh watchdog wrapper + stub tests
This commit is contained in:
1 parent
d0035498fa
commit
fa433da81a
4 files changed
+114
No files matched your search
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# fake codex: emits one event then hangs silently
|
||||
echo '{"type":"thread.started","thread_id":"hang-thread-456"}'
|
||||
sleep 300
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# fake codex: emits thread.started, writes last message file, exits 0
|
||||
out=""
|
||||
prev=""
|
||||
for a in "$@"; do [[ $prev == "-o" ]] && out=$a; prev=$a; done
|
||||
echo '{"type":"thread.started","thread_id":"test-thread-123"}'
|
||||
echo '{"type":"turn.completed"}'
|
||||
echo "stub answer" > "$out"
|
||||
exit 0
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/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" ]]
|
||||
|
||||
# 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 ]]
|
||||
|
||||
echo "ALL PASS"
|
||||
Reference in new issue
Block a user