-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·105 lines (88 loc) · 3.03 KB
/
run-tests.sh
File metadata and controls
executable file
·105 lines (88 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Pilaf Test Runner
# Starts a local Minecraft server and runs Pilaf tests with HTML report generation
set -e
echo "🎮 Pilaf Test Runner"
echo "=================="
# Load environment variables from .env file if it exists
if [ -f .env ]; then
echo "📋 Loading custom configuration from .env"
export $(cat .env | grep -v '^#' | grep -v '^$' | xargs)
fi
# Set defaults if not already set
export RCON_HOST="${RCON_HOST:-localhost}"
export RCON_PORT="${RCON_PORT:-25576}"
export RCON_PASSWORD="${RCON_PASSWORD:-cavarest}"
export MC_HOST="${MC_HOST:-localhost}"
export MC_PORT="${MC_PORT:-25566}"
echo "📋 Configuration:"
echo " Minecraft: $MC_HOST:$MC_PORT"
echo " RCON: $RCON_HOST:$RCON_PORT"
echo ""
# Check if Docker is running
if ! docker ps > /dev/null 2>&1; then
echo "❌ Docker is not running!"
echo "Please start Docker Desktop and try again."
exit 1
fi
# Check if server is already running
if docker ps | grep -q "pilaf-minecraft-dev"; then
echo "✅ Minecraft server already running"
else
echo "🚀 Starting Minecraft server..."
docker-compose -f docker-compose.dev.yml up -d
echo "⏳ Waiting for server to initialize (this takes 60-90 seconds)..."
echo "You can watch logs with: docker-compose -f docker-compose.dev.yml logs -f"
echo ""
# Wait for RCON port to be accessible (using timeout with TCP connection)
# We'll wait up to 90 seconds for the server to be ready
echo "Waiting for RCON port $RCON_PORT to be accessible..."
for i in {1..45}; do
if timeout 1 bash -c "cat < /dev/null > /dev/tcp/$RCON_HOST/$RCON_PORT" 2>/dev/null; then
echo ""
echo "✅ Server is ready!"
break
fi
echo -n "."
sleep 2
done
if ! timeout 1 bash -c "cat < /dev/null > /dev/tcp/$RCON_HOST/$RCON_PORT" 2>/dev/null; then
echo ""
echo "❌ Server failed to start. Check logs: docker-compose -f docker-compose.dev.yml logs"
docker-compose -f docker-compose.dev.yml down
exit 1
fi
fi
echo ""
echo "🧪 Running tests and generating HTML report..."
echo "=================="
# Always generate report
pnpm test:report
# Save exit code
TEST_EXIT_CODE=$?
echo ""
echo "=================="
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "✅ All tests passed!"
echo ""
echo "📊 HTML Report: target/pilaf-reports/index.html"
echo ""
# Try to open the report automatically
if command -v open &> /dev/null; then
open target/pilaf-reports/index.html 2>/dev/null || true
elif command -v xdg-open &> /dev/null; then
xdg-open target/pilaf-reports/index.html 2>/dev/null || true
fi
else
echo "❌ Some tests failed."
echo ""
echo "📊 Check the report for details: target/pilaf-reports/index.html"
fi
echo ""
echo "💡 Server is still running. Stop it with:"
echo " docker-compose -f docker-compose.dev.yml down"
echo ""
echo "💡 Or connect to it with a Minecraft client:"
echo " Address: $MC_HOST"
echo " Port: $MC_PORT"
exit $TEST_EXIT_CODE