#!/usr/bin/env bash set -ex ROOT="$(cd "$(dirname "$0")" && pwd)" cd "$ROOT" TEST_DB=${MUD_TEST_DB:-./mudserver.db.test} SERVER_PID= ssh_mud() { set +e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 "$@" r=$? set -e [[ $r -eq 0 || $r -eq 255 ]] || exit 1 } 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=$! bash "$ROOT/scripts/ci/wait-for-tcp.sh" 127.0.0.1 2222 ssh_mud smoketest@localhost <<'EOF' 1 1 look stats go south go down go north talk barkeep go south go south examine thief attack thief flee quit EOF ssh_mud smoketest@localhost <<'EOF' look stats quit EOF ./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 ssh_mud smoketest@localhost <<'EOF' admin help admin list admin registration on admin info smoketest quit EOF ./target/debug/mudtool -d "$TEST_DB" settings set registration_open false ssh_mud newplayer@localhost <<'EOF' quit EOF ./target/debug/mudtool -d "$TEST_DB" settings set registration_open true ./target/debug/mudtool -d "$TEST_DB" players delete smoketest ( echo "1" echo "1" echo "go south" echo "go down" echo "go south" echo "attack thief" sleep 8 echo "stats" echo "quit" ) | ssh_mud smoketest@localhost ./target/debug/mudtool -d "$TEST_DB" settings set registration_open true ./target/debug/mudtool -d "$TEST_DB" players delete smoketest