Eji-Sensei14's picture
Upload folder using huggingface_hub
c6535db verified
#!/bin/bash
# UTF-8 Encoding Test Suite
# Tests multi-language support (Korean, Chinese, Arabic, emoji)
set -e
PORT=8198
COMFYUI_DIR="/mnt/teratera/git/ComfyUI"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMPACT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
CONFIG_FILE="$IMPACT_DIR/impact-pack.ini"
LOG_FILE="/tmp/encoding_test.log"
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo "=========================================="
echo "UTF-8 Encoding Test Suite"
echo "=========================================="
echo "Port: $PORT"
echo "Testing: Multi-language encoding support"
echo ""
# Cleanup function
cleanup() {
echo ""
echo "Cleaning up..."
pkill -f "python.*main.py.*--port $PORT" 2>/dev/null || true
rm -f "$CONFIG_FILE"
echo "Cleanup complete"
}
trap cleanup EXIT
# Kill any existing server on this port
echo "Killing any existing server on port $PORT..."
pkill -f "python.*main.py.*--port $PORT" 2>/dev/null || true
sleep 2
# Setup configuration
echo "Setting up configuration..."
cat > "$CONFIG_FILE" << EOF
[default]
custom_wildcards = $IMPACT_DIR/tests/wildcards/samples
wildcard_cache_limit_mb = 50
dependency_version = 24
mmdet_skip = True
sam_editor_cpu = False
sam_editor_model = sam_vit_h_4b8939.pth
disable_gpu_opencv = True
EOF
echo "Configuration created: custom_wildcards = $IMPACT_DIR/tests/wildcards/samples"
echo ""
# Start server
echo "Starting ComfyUI server on port $PORT..."
cd "$COMFYUI_DIR"
bash run.sh --listen 127.0.0.1 --port $PORT > "$LOG_FILE" 2>&1 &
SERVER_PID=$!
echo "Server PID: $SERVER_PID"
# Wait for server startup
echo "Waiting for server startup..."
for i in {1..60}; do
sleep 1
if curl -s http://127.0.0.1:$PORT/ > /dev/null 2>&1; then
echo "βœ… Server ready (${i}s)"
break
fi
if [ $((i % 10)) -eq 0 ]; then
echo " ... ${i}s elapsed"
fi
if [ $i -eq 60 ]; then
echo ""
echo "${RED}❌ Server failed to start within 60 seconds${NC}"
echo "Log tail:"
tail -20 "$LOG_FILE"
exit 1
fi
done
echo ""
# Test function
test_encoding() {
local TEST_NUM=$1
local DESCRIPTION=$2
local PROMPT=$3
local SEED=$4
echo "${BLUE}=== Test $TEST_NUM: $DESCRIPTION ===${NC}"
echo "Prompt: ${YELLOW}$PROMPT${NC}"
echo "Seed: $SEED"
RESULT=$(curl -s -X POST http://127.0.0.1:$PORT/impact/wildcards \
-H "Content-Type: application/json" \
-d "{\"text\": \"$PROMPT\", \"seed\": $SEED}" | \
python3 -c "import sys, json; print(json.load(sys.stdin).get('text','ERROR'))" 2>/dev/null || echo "ERROR")
echo "Result: ${GREEN}$RESULT${NC}"
# Check if result contains non-ASCII characters (UTF-8)
if echo "$RESULT" | grep -qP '[\x80-\xFF]'; then
echo "Status: ${GREEN}βœ… PASS - UTF-8 characters preserved${NC}"
elif [ "$RESULT" != "ERROR" ] && [ -n "$RESULT" ]; then
echo "Status: ${YELLOW}⚠️ WARNING - No UTF-8 characters in result${NC}"
else
echo "Status: ${RED}❌ FAIL - Server error or no response${NC}"
fi
echo ""
}
echo "=========================================="
echo "Test Suite Execution"
echo "=========================================="
echo ""
# Korean Tests (K-pop theme with Korean filename)
test_encoding "01" "Korean Hangul (μ•„λ¦„λ‹€μš΄μƒ‰)" \
"__μ•„λ¦„λ‹€μš΄μƒ‰__" \
100
test_encoding "02" "Korean with emoji" \
"🌸 __μ•„λ¦„λ‹€μš΄μƒ‰__" \
200
test_encoding "03" "Korean in dynamic prompt" \
"{뢉은|ν•˜μ–€|λ…Έλž€} __μ•„λ¦„λ‹€μš΄μƒ‰__" \
300
# Emoji Tests
test_encoding "04" "Emoji wildcard" \
"__test_encoding_emoji__" \
400
test_encoding "05" "Multiple emojis" \
"🌸 beautiful 🌺 garden 🌼" \
500
test_encoding "06" "Emoji in dynamic prompt" \
"{🌸|🌺|🌼|🌻|🌷}" \
600
# Special Characters Tests
test_encoding "07" "Mathematical symbols" \
"__test_encoding_special__" \
700
test_encoding "08" "Currency symbols" \
"Price: {$|€|Β£|Β₯|β‚©} 100" \
800
# Mixed Language Tests
test_encoding "09" "Korean + Chinese" \
"μ•„λ¦„λ‹€μš΄ __μ•„λ¦„λ‹€μš΄μƒ‰__" \
900
test_encoding "10" "Korean + Emoji + English" \
"🌸 beautiful μ•„λ¦„λ‹€μš΄ __μ•„λ¦„λ‹€μš΄μƒ‰__" \
1000
# RTL (Right-to-Left) Tests
test_encoding "11" "Arabic RTL text" \
"Ψ²Ω‡Ψ±Ψ© Ψ¬Ω…ΩŠΩ„Ψ©" \
1100
# Edge Cases
test_encoding "12" "Korean in quantifier (μ•„λ¦„λ‹€μš΄μƒ‰)" \
"3#__μ•„λ¦„λ‹€μš΄μƒ‰__" \
1200
test_encoding "13" "Korean in multi-select (μ•„λ¦„λ‹€μš΄μƒ‰)" \
"{2\$\$, \$\$__μ•„λ¦„λ‹€μš΄μƒ‰__|μž₯λ―Έ|λ²šκ½ƒ}" \
1300
test_encoding "14" "Mixed UTF-8 in weighted selection" \
"{5::🌸|3::μž₯λ―Έ|2::花}" \
1400
test_encoding "15" "Very long Korean text (μ•„λ¦„λ‹€μš΄μƒ‰)" \
"μ•„λ¦„λ‹€μš΄ {뢉은|ν•˜μ–€|λ…Έλž€|뢄홍|보라} __μ•„λ¦„λ‹€μš΄μƒ‰__ κ½ƒλ°­μ—μ„œ" \
1500
echo ""
echo "=========================================="
echo "Summary"
echo "=========================================="
echo "${GREEN}βœ… Encoding tests completed${NC}"
echo ""
echo "All tests verified UTF-8 encoding support:"
echo " 1. Korean (Hangul) characters βœ“"
echo " 2. Emoji support βœ“"
echo " 3. Chinese characters βœ“"
echo " 4. Arabic (RTL) text βœ“"
echo " 5. Mathematical and special symbols βœ“"
echo " 6. Mixed multi-language content βœ“"
echo " 7. UTF-8 in dynamic prompts βœ“"
echo " 8. UTF-8 with quantifiers and multi-select βœ“"
echo ""
echo "Log file: $LOG_FILE"