Skip to content

Commit 3cb61ea

Browse files
committed
Add CI PTY edit coverage
1 parent c4b0ca4 commit 3cb61ea

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ jobs:
2424
github-token: ${{ secrets.GITHUB_TOKEN }}
2525

2626
- name: Run checks
27+
env:
28+
CLAI_ENABLE_PTY_TESTS: "true"
2729
run: make check

test/smoke.bats

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,52 @@ EOF
896896
[ "$(cat "$TEST_HOME/cmd-edited.txt")" = "edited" ]
897897
}
898898

899+
@test "command responses can be edited through a real PTY session" {
900+
if [ "${CLAI_ENABLE_PTY_TESTS:-false}" != "true" ]; then
901+
skip "PTY-backed edit test is disabled in this environment"
902+
fi
903+
904+
if ! command -v script >/dev/null 2>&1; then
905+
skip "script command is unavailable"
906+
fi
907+
908+
write_config <<'EOF'
909+
key=test-key
910+
hi_contrast=false
911+
expose_current_dir=true
912+
max_history_turns=10
913+
api=https://example.invalid/v1/chat/completions
914+
model=gpt-4o-mini
915+
json_mode=false
916+
temp=0.1
917+
tokens=500
918+
exec_query=
919+
question_query=
920+
error_query=
921+
EOF
922+
923+
make_command_curl
924+
925+
printf 'eprintf edited-pty > "%s/cmd-edited-pty.txt"\n' "$TEST_HOME" > "$TEST_HOME/edit-input.txt"
926+
927+
run bash -lc '
928+
env \
929+
HOME="'"$TEST_HOME"'" \
930+
TMPDIR="'"$TEST_HOME"'/tmp" \
931+
PATH="'"$TEST_HOME"'/fakebin:$PATH" \
932+
USER="bats" \
933+
LANG="C" \
934+
LC_TIME="C" \
935+
TEST_HOME="'"$TEST_HOME"'" \
936+
script -qec "bash ./clai.sh \"run the command\"" /dev/null < "'"$TEST_HOME"'/edit-input.txt"
937+
'
938+
939+
[ "$status" -eq 0 ]
940+
[ ! -e "$TEST_HOME/cmd-ran.txt" ]
941+
[ -f "$TEST_HOME/cmd-edited-pty.txt" ]
942+
[ "$(cat "$TEST_HOME/cmd-edited-pty.txt")" = "edited-pty" ]
943+
}
944+
899945
@test "missing assistant message content falls back to an unknown error" {
900946
write_config <<'EOF'
901947
key=test-key

0 commit comments

Comments
 (0)