Skip to content

Commit bb2b457

Browse files
committed
Add local smoke test script for faster iteration
Added test-smoke.sh so developers can test locally before pushing to CI. Usage: ./test-smoke.sh The script: - Downloads BAR engine if needed - Sets up game directory structure - Creates Spring config (disables audio) - Runs SpringBoard for 10 seconds with Xvfb - Validates LuaUI loaded and checks for crashes - Reports results This allows testing the smoke test logic locally without waiting for CI, making iteration much faster.
1 parent dc88020 commit bb2b457

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

test-smoke.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/bash
2+
# Local smoke test runner
3+
# Run this script to test SpringBoard locally before pushing to CI
4+
5+
set -e
6+
7+
echo "=== SpringBoard Local Smoke Test ==="
8+
echo ""
9+
10+
# Check if we're in the right directory
11+
if [ ! -f "modinfo.lua" ]; then
12+
echo "Error: Run this script from SpringBoard-Core root directory"
13+
exit 1
14+
fi
15+
16+
# Check dependencies
17+
echo "Checking dependencies..."
18+
command -v wget >/dev/null 2>&1 || { echo "Error: wget not installed"; exit 1; }
19+
command -v 7z >/dev/null 2>&1 || { echo "Error: p7zip not installed"; exit 1; }
20+
command -v xvfb-run >/dev/null 2>&1 || { echo "Error: xvfb not installed"; exit 1; }
21+
echo "✓ Dependencies OK"
22+
echo ""
23+
24+
# Download engine if not present
25+
if [ ! -f "spring" ]; then
26+
echo "Downloading BAR Engine..."
27+
wget -q "https://github.com/beyond-all-reason/spring/releases/download/spring_bar_%7BBAR105%7D105.1.1-2472-ga5aa45c/spring_bar_.BAR105.105.1.1-2472-ga5aa45c_linux-64-minimal-portable.7z"
28+
7z x -y "spring_bar_.BAR105.105.1.1-2472-ga5aa45c_linux-64-minimal-portable.7z"
29+
rm *.7z
30+
chmod +x spring
31+
echo "✓ Engine downloaded"
32+
else
33+
echo "✓ Engine already present"
34+
fi
35+
echo ""
36+
37+
# Setup game directory
38+
echo "Setting up game directory..."
39+
mkdir -p games
40+
ln -sf "$(pwd)" "games/SpringBoard Core.sdd"
41+
echo "✓ Game directory set up"
42+
echo ""
43+
44+
# Create config to disable audio
45+
echo "Creating Spring config..."
46+
mkdir -p test-data
47+
cat > test-data/springsettings.cfg << 'EOF'
48+
snd_disable = 1
49+
snd_volmaster = 0
50+
EOF
51+
echo "✓ Config created"
52+
echo ""
53+
54+
# Create script.txt
55+
echo "Creating Spring script..."
56+
cat > script.txt << 'EOF'
57+
[GAME]
58+
{
59+
GameType=SpringBoard Core;
60+
MapName=sb_initial_blank_10x8;
61+
IsHost=1;
62+
MyPlayerName=TestPlayer;
63+
[MODOPTIONS]
64+
{
65+
MapSeed=42;
66+
new_map_x=10;
67+
new_map_y=8;
68+
}
69+
[PLAYER0]
70+
{
71+
Name=TestPlayer;
72+
Team=0;
73+
IsFromDemo=0;
74+
Spectator=1;
75+
}
76+
[TEAM0]
77+
{
78+
TeamLeader=0;
79+
AllyTeam=0;
80+
}
81+
[ALLYTEAM0]
82+
{
83+
}
84+
}
85+
EOF
86+
echo "✓ Script created"
87+
echo ""
88+
89+
# Run the test
90+
echo "=== Running SpringBoard with Xvfb ==="
91+
echo "This will run for 10 seconds..."
92+
echo ""
93+
94+
timeout 10s xvfb-run -a -s "-screen 0 1024x768x24" \
95+
./spring --write-dir $(pwd)/test-data script.txt || EXIT_CODE=$?
96+
97+
sleep 2
98+
99+
echo ""
100+
echo "=== Test Results ==="
101+
echo "Exit code: ${EXIT_CODE:-0}"
102+
echo ""
103+
104+
# Validate results
105+
if [ ! -f test-data/infolog.txt ]; then
106+
echo "✗ FAIL: No infolog.txt generated"
107+
exit 1
108+
fi
109+
110+
if grep -q "CrashHandler.*Error.*Aborted\|XIO.*fatal.*error\|terminate called" test-data/infolog.txt; then
111+
echo "✗ FAIL: Spring crashed"
112+
echo ""
113+
tail -50 test-data/infolog.txt
114+
exit 1
115+
fi
116+
117+
if ! grep -q "LuaUI.*Loaded\|Loading LuaUI" test-data/infolog.txt; then
118+
echo "✗ FAIL: LuaUI did not load"
119+
echo ""
120+
tail -50 test-data/infolog.txt
121+
exit 1
122+
fi
123+
124+
echo "✓ LuaUI loaded"
125+
126+
if grep -q -i "rmlui" test-data/infolog.txt; then
127+
echo "✓ RmlUi found in logs"
128+
grep -i "rmlui" test-data/infolog.txt | head -5
129+
else
130+
echo "⚠ Warning: No RmlUi messages"
131+
fi
132+
133+
echo ""
134+
echo "✓✓✓ SMOKE TEST PASSED ✓✓✓"
135+
echo ""
136+
echo "View full log: test-data/infolog.txt"

0 commit comments

Comments
 (0)