test(entrypoint): 覆蓋 Codex transcript 重複輸出

This commit is contained in:
2026-06-24 14:16:47 +00:00
parent cab7507ddb
commit ffdb53c645
+35
View File
@@ -56,6 +56,26 @@ SH
chmod +x "$dir/codex" chmod +x "$dir/codex"
} }
make_fake_transcript_codex() {
local dir="$1"
cat > "$dir/codex" <<'SH'
#!/bin/sh
last_message_file=""
while [ "$#" -gt 0 ]; do
if [ "$1" = "--output-last-message" ]; then
shift
last_message_file="$1"
fi
shift
done
printf '%s\n' 'codex' 'final answer' 'tokens used' '123' 'final answer'
printf '%s\n' 'final answer' > "$last_message_file"
SH
chmod +x "$dir/codex"
}
encoded_json() { encoded_json() {
printf '%s' "$1" | base64 | tr -d '\n' printf '%s' "$1" | base64 | tr -d '\n'
} }
@@ -269,6 +289,20 @@ test_codex_output_truncation() {
rm -rf "$tmpdir" rm -rf "$tmpdir"
} }
test_last_message_output_without_transcript_duplicate() {
local tmpdir
tmpdir="$(mktemp -d)"
make_fake_transcript_codex "$tmpdir"
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="hello"
[[ "$(grep -c "final answer" "$tmpdir/stdout")" -eq 1 ]] || die "stdout printed final answer more than once"
grep -q "status=completed" "$tmpdir/github-output" || die "last message completed status"
[[ "$(grep -c "final answer" "$tmpdir/github-output")" -eq 1 ]] || die "github output included transcript duplicate"
! grep -q "tokens used" "$tmpdir/github-output" || die "github output included codex transcript"
rm -rf "$tmpdir"
}
test_invalid_execution_config_uses_defaults() { test_invalid_execution_config_uses_defaults() {
local tmpdir local tmpdir
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
@@ -299,6 +333,7 @@ test_missing_codex_command_output
test_codex_timeout_output test_codex_timeout_output
test_codex_signal_output test_codex_signal_output
test_codex_output_truncation test_codex_output_truncation
test_last_message_output_without_transcript_duplicate
test_invalid_execution_config_uses_defaults test_invalid_execution_config_uses_defaults
echo "entrypoint tests passed" echo "entrypoint tests passed"