From a01dbe5e2c1b5500546ad0b122db72fd41cb60ff Mon Sep 17 00:00:00 2001 From: Jeffery Date: Wed, 24 Jun 2026 13:09:34 +0000 Subject: [PATCH] =?UTF-8?q?test(entrypoint):=20=E8=A3=9C=E4=B8=8A=20prompt?= =?UTF-8?q?=20=E9=82=8A=E7=95=8C=E8=88=87=E6=98=A0=E5=83=8F=E6=AA=94=20smo?= =?UTF-8?q?ke=20=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/docker_image_test.sh | 22 ++++++++++++++++++++++ tests/entrypoint_test.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 tests/docker_image_test.sh diff --git a/tests/docker_image_test.sh b/tests/docker_image_test.sh new file mode 100755 index 0000000..25d1d48 --- /dev/null +++ b/tests/docker_image_test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +IMAGE_NAME="codex-action-smoke:local" + +if ! command -v docker >/dev/null 2>&1; then + echo "SKIP: docker is not available" + exit 0 +fi + +if ! docker info >/dev/null 2>&1; then + echo "SKIP: docker daemon is not available" + exit 0 +fi + +docker build -t "$IMAGE_NAME" "$ROOT_DIR" + +docker run --rm --entrypoint codex "$IMAGE_NAME" --version +docker run --rm --entrypoint codex "$IMAGE_NAME" plugin list | grep -q "jsc@doc" +docker run --rm --entrypoint codex "$IMAGE_NAME" plugin list | grep -q "jsc@code-review" diff --git a/tests/entrypoint_test.sh b/tests/entrypoint_test.sh index bc38fca..8055217 100755 --- a/tests/entrypoint_test.sh +++ b/tests/entrypoint_test.sh @@ -16,6 +16,7 @@ make_fake_codex() { cat > "$dir/codex" < "\${CODEX_FAKE_ARGS:-/dev/null}" echo "$message" exit $exit_code SH @@ -118,6 +119,30 @@ test_success_output() { rm -rf "$tmpdir" } +test_empty_prompt() { + local tmpdir + tmpdir="$(mktemp -d)" + make_fake_codex "$tmpdir" 0 "codex ok" + + run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="" + + grep -q "codex ok" "$tmpdir/github-output" || die "empty prompt output" + rm -rf "$tmpdir" +} + +test_prompt_with_shell_characters() { + local tmpdir + local prompt + tmpdir="$(mktemp -d)" + prompt='hello; rm -rf / $(echo bad) "quoted"' + make_fake_codex "$tmpdir" 0 "codex ok" + + run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="$prompt" CODEX_FAKE_ARGS="$tmpdir/codex-args" + + grep -qF "$prompt" "$tmpdir/codex-args" || die "prompt was not passed as one argument" + rm -rf "$tmpdir" +} + test_failure_output() { local tmpdir tmpdir="$(mktemp -d)" @@ -140,6 +165,8 @@ test_missing_model test_invalid_base64 test_non_object_json test_success_output +test_empty_prompt +test_prompt_with_shell_characters test_failure_output echo "entrypoint tests passed"