From 35aade44f4eb9870055b6d91f893609b8e18e8b1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 24 Aug 2025 11:35:06 +1200 Subject: [PATCH] Update test.sh --- test.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test.sh b/test.sh index 0c6732f..787a466 100755 --- a/test.sh +++ b/test.sh @@ -230,14 +230,22 @@ function start_test_server() { fi # If that didn't work, try host IP with mapped port (Docker-in-Docker) - if [ "$http_code" = "000" ] && [ -n "${HOST_IP}" ]; then - http_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://${HOST_IP}:${TEST_PORT}/" 2>/dev/null || echo "000") - test_urls="${test_urls}, host:${HOST_IP}:${TEST_PORT}" + if [ "$http_code" = "000" ] || [ "$http_code" = "" ]; then + if [ -n "${HOST_IP}" ]; then + local host_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://${HOST_IP}:${TEST_PORT}/" 2>/dev/null || echo "000") + if [ "$host_code" != "000" ] && [ "$host_code" != "" ]; then + http_code="$host_code" + fi + test_urls="${test_urls}, host:${HOST_IP}:${TEST_PORT}" + fi fi # If that didn't work, try localhost with mapped port (local Docker) - if [ "$http_code" = "000" ]; then - http_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://localhost:${TEST_PORT}/" 2>/dev/null || echo "000") + if [ "$http_code" = "000" ] || [ "$http_code" = "" ]; then + local local_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://localhost:${TEST_PORT}/" 2>/dev/null || echo "000") + if [ "$local_code" != "000" ] && [ "$local_code" != "" ]; then + http_code="$local_code" + fi test_urls="${test_urls}, localhost:${TEST_PORT}" fi