Skip to main content

Test architecture

LandSandBoat has a custom test framework built into the xi_test binary. Tests are written in Lua using a BDD-style describe/it API, and the test runner is a dedicated process (src/test/) that spins up a full in-memory MapEngine and WorldEngine against a live database.

Running tests locally

The dev.docker-compose.yml test service runs xi_test against a containerized MariaDB:
The --keep-going flag ensures all tests run even if some fail.

Without Docker

Build xi_test with CMake and run it directly:
xi_test requires a running MariaDB instance with a populated database. Use environment variables to configure the connection:

Writing Lua tests

Test files live under scripts/tests/ and use a describe/it BDD API. The test runner discovers all .lua files in that tree automatically.

Basic test structure

Lifecycle hooks

CClientEntityPair

xi.test.world:spawnPlayer(...) returns a CClientEntityPair — a coupled (client, server entity) pair that lets you drive the player from the Lua test:

Test specs (type definitions)

scripts/specs/ contains Lua type definition files (LuaLS annotations) for all binding types. These are picked up by the Lua Language Server and provide autocomplete and type checking in editors:

Startup checks

The startup_checks service (run as python -m tools.ci.startup_checks) validates that the server can start cleanly — including zone initialization, Lua loading, and basic sanity checks — without running the full test suite.

Static analysis — clang-tidy

clang-tidy runs as a separate build in CI and locally via Docker:
The enabled checks are defined in .clang-tidy at the repository root. See Code style for the full list.

CI workflows

CI is handled by GitHub Actions. The relevant workflows are:

Build matrix

The Builds workflow compiles on:

Test matrix

The Tests workflow runs after a successful build:
  • Sanity checks — shell-based checks run against origin/base
  • Lua Language Server — type-checks all Lua scripts
  • Runner tests — xi_test on Windows and macOS
  • Docker tests — xi_test + startup checks on Ubuntu and Alpine containers
All of these checks can be run locally using dev.docker-compose.yml services before pushing. See Development workflow for service names and commands.