From 9c286823e62f0a66f9d90139844c06910339a71b Mon Sep 17 00:00:00 2001 From: AI Agent Date: Sat, 14 Mar 2026 18:06:54 -0600 Subject: [PATCH] Update TESTING.md to include prerequisites for running tests, specifying the need for the Rust toolchain and SSH client. --- .gitea/workflows/smoke-tests.yml | 21 ++++++++ TESTING.md | 2 + run-tests.sh | 82 ++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 .gitea/workflows/smoke-tests.yml create mode 100755 run-tests.sh diff --git a/.gitea/workflows/smoke-tests.yml b/.gitea/workflows/smoke-tests.yml new file mode 100644 index 0000000..2f36c20 --- /dev/null +++ b/.gitea/workflows/smoke-tests.yml @@ -0,0 +1,21 @@ +name: Smoke tests +on: [push, pull_request] + +jobs: + smoke: + name: Build and smoke test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + run: sudo apt install -y cargo + + - name: clone repository + action: actions/checkout@v4 + + - name: Build + run: cargo build + + - name: Run smoke tests + run: ./run-tests.sh diff --git a/TESTING.md b/TESTING.md index 96a5e6b..69f5337 100644 --- a/TESTING.md +++ b/TESTING.md @@ -8,6 +8,8 @@ This builds the server and mudtool, starts the server with a temporary DB, runs the smoke test below (new player, persistence, admin, registration gate, combat), then cleans up. Use it locally to match what Gitea Actions run on push/pull_request. The script uses `MUD_TEST_DB` (default `./mudserver.db.test`) so it does not overwrite your normal `mudserver.db`. +Prerequisites: Rust toolchain (cargo), ssh client. In CI, Rust is installed by the workflow. + --- Run through the checks below before every commit to ensure consistent feature coverage. diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..4414f3b --- /dev/null +++ b/run-tests.sh @@ -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