Update TESTING.md to include prerequisites for running tests, specifying the need for the Rust toolchain and SSH client.
Some checks failed
Smoke tests / Build and smoke test (push) Failing after 0s
Some checks failed
Smoke tests / Build and smoke test (push) Failing after 0s
This commit is contained in:
82
run-tests.sh
Executable file
82
run-tests.sh
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
TEST_DB=${MUD_TEST_DB:-./mudserver.db.test}
|
||||
SERVER_PID=
|
||||
|
||||
cleanup() {
|
||||
if [ -n "${SERVER_PID:-}" ]; then
|
||||
kill $SERVER_PID 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
cargo build
|
||||
RUST_LOG=info ./target/debug/mudserver -d "$TEST_DB" &
|
||||
SERVER_PID=$!
|
||||
sleep 2
|
||||
|
||||
# Test 1: New player creation + basic commands
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
1
|
||||
1
|
||||
look
|
||||
stats
|
||||
go north
|
||||
talk barkeep
|
||||
go south
|
||||
go south
|
||||
examine thief
|
||||
attack thief
|
||||
flee
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 2: Persistence - reconnect
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
look
|
||||
stats
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 3: Admin via mudtool (use same test DB)
|
||||
./target/debug/mudtool -d "$TEST_DB" players list
|
||||
./target/debug/mudtool -d "$TEST_DB" players set-admin smoketest true
|
||||
./target/debug/mudtool -d "$TEST_DB" players show smoketest
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open false
|
||||
./target/debug/mudtool -d "$TEST_DB" settings list
|
||||
|
||||
# Test 4: Admin commands in-game
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
admin help
|
||||
admin list
|
||||
admin registration on
|
||||
admin info smoketest
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 5: Registration gate
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open false
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 newplayer@localhost <<'EOF'
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 6: Tick-based combat (connect and wait for ticks)
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open true
|
||||
./target/debug/mudtool -d "$TEST_DB" players delete smoketest
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
1
|
||||
1
|
||||
go south
|
||||
go south
|
||||
attack thief
|
||||
EOF
|
||||
sleep 8
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
stats
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Cleanup (trap handles server kill)
|
||||
./target/debug/mudtool -d "$TEST_DB" settings set registration_open true
|
||||
./target/debug/mudtool -d "$TEST_DB" players delete smoketest
|
||||
Reference in New Issue
Block a user