-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_unity.sh
More file actions
executable file
·89 lines (76 loc) · 2.74 KB
/
Copy pathtest_unity.sh
File metadata and controls
executable file
·89 lines (76 loc) · 2.74 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
#!/bin/bash
set -e
UNITY="/Applications/Unity/Hub/Editor/2022.3.62f3c1/Unity.app/Contents/MacOS/Unity"
PROJECT="/Users/boom/Demo/BoomNetworkUnity/Untiy"
RESULTS="/Users/boom/Demo/BoomNetworkUnity/test-results"
SVR_DIR="/Users/boom/Demo/BoomNetwork/svr"
mkdir -p "$RESULTS"
MODE="${1:-edit}" # edit, play, all
start_server() {
lsof -ti:9000 2>/dev/null | xargs kill -9 2>/dev/null || true
sleep 0.3
cd "$SVR_DIR"
go run ./cmd/framesync/ -addr=:9000 -ppr=2 > /dev/null 2>&1 &
SERVER_PID=$!
sleep 1
echo " Go server started (pid=$SERVER_PID)"
}
stop_server() {
lsof -ti:9000 2>/dev/null | xargs kill -9 2>/dev/null || true
echo " Go server stopped"
}
echo "=========================================="
echo " Unity CLI Test Runner"
echo " Mode: $MODE"
echo "=========================================="
if [ "$MODE" = "edit" ] || [ "$MODE" = "all" ]; then
echo ""
echo "[EditMode] Running Codec + Framing tests..."
"$UNITY" \
-batchmode \
-nographics \
-projectPath "$PROJECT" \
-runTests \
-testPlatform EditMode \
-testResults "$RESULTS/editmode.xml" \
-logFile "$RESULTS/editmode.log" \
2>&1
if grep -q 'result="Failed"' "$RESULTS/editmode.xml" 2>/dev/null; then
echo " ✗ EditMode FAILED"
grep 'message=' "$RESULTS/editmode.xml" | head -5
[ "$MODE" = "edit" ] && exit 1
else
PASSED=$(grep -c 'result="Passed"' "$RESULTS/editmode.xml" 2>/dev/null || echo 0)
echo " ✓ EditMode: $PASSED tests passed"
fi
fi
if [ "$MODE" = "play" ] || [ "$MODE" = "all" ]; then
echo ""
echo "[PlayMode] Running FrameSync integration tests..."
# 每次重启服务器确保状态干净
start_server
"$UNITY" \
-batchmode \
-nographics \
-projectPath "$PROJECT" \
-runTests \
-testPlatform PlayMode \
-testResults "$RESULTS/playmode.xml" \
-logFile "$RESULTS/playmode.log" \
2>&1
stop_server
if grep -q 'test-case.*result="Failed"' "$RESULTS/playmode.xml" 2>/dev/null; then
PASSED=$(grep -c 'result="Passed"' "$RESULTS/playmode.xml" 2>/dev/null || echo 0)
FAILED=$(grep -c 'test-case.*result="Failed"' "$RESULTS/playmode.xml" 2>/dev/null || echo 0)
echo " ✗ PlayMode: $PASSED passed, $FAILED failed"
grep -B1 'message=' "$RESULTS/playmode.xml" | grep 'message=' | head -5
[ "$MODE" = "play" ] && exit 1
else
PASSED=$(grep -c 'result="Passed"' "$RESULTS/playmode.xml" 2>/dev/null || echo 0)
echo " ✓ PlayMode: $PASSED tests passed"
fi
fi
echo ""
echo "=========================================="
echo " Results saved to: $RESULTS/"
echo "=========================================="