From 2c28c53bcc408c440441232bc1732870a6d40219 Mon Sep 17 00:00:00 2001 From: Sagent Date: Mon, 8 Jun 2026 20:45:01 +0000 Subject: [PATCH] fix: avoid pipefail/SIGPIPE by using temp files for HTTP tests --- tests/test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 88eaad9..945f415 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -58,10 +58,16 @@ done echo "" echo "Test: GET /" -RESPONSE=$(curl -sf -D - "$BASE_URL/") -STATUS=$(echo "$RESPONSE" | head -1 | grep -oP '\d{3}') -CONTENT_TYPE=$(echo "$RESPONSE" | grep -i 'content-type' | tr -d '\r' | cut -d: -f2- | xargs) -BODY=$(echo "$RESPONSE" | sed -n '/^\r$/,$p' | tail -n +2) +TMPDIR=$(mktemp -d) +cleanup() { + docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true + rm -rf "$TMPDIR" +} +curl -sf -o "$TMPDIR/body" -D "$TMPDIR/headers" "$BASE_URL/" +STATUS=$(head -1 "$TMPDIR/headers" | grep -oP '\d{3}') +CONTENT_TYPE=$(grep -i 'content-type' "$TMPDIR/headers" | tr -d '\r' | cut -d: -f2- | xargs) +BODY=$(cat "$TMPDIR/body") +trap cleanup EXIT assert "HTTP status is 200" "200" "$STATUS" assert_match "Content-Type is text/html" "text/html" "$CONTENT_TYPE"