Merge pull request #1837 from ludovic111/feat/server-mod-test-scripts
🤖 Agent: The test scripts for server mods. CI is green ond64bd7c52, and the PR is now based on main after #1833 merged. I ran pr_ready --quick on this head merged with main (b8027d4b1): fmt, clippy, the horizon-mods and welcome tests (48) and the launcher tests (132) all pass. The only affected harness is lan_integration, which runs in CI. Queued.
This commit is contained in:
+13
-1
@@ -251,7 +251,8 @@ key> --signature <file>.minisig`.
|
||||
`cargo horizon-mod test` builds the mod, then runs each `tests/<name>.toml` in
|
||||
the sandbox the game uses, with no game and no window: the test plays the
|
||||
game's part (the player and the clock the mod reads, ticks, frames, chat lines,
|
||||
commands) and checks what the mod showed. A script fails at its first wrong
|
||||
commands; for a server mod, players joining, chatting, typing commands,
|
||||
breaking and placing blocks and leaving) and checks what the mod showed. A script fails at its first wrong
|
||||
step, with what it expected and what it got; the command fails if any script
|
||||
does. `--debug` builds without optimizing, `--hmod <file>` tests a `.hmod`
|
||||
already built, and a name runs only the scripts whose path holds it. Each
|
||||
@@ -288,6 +289,16 @@ A step's parts happen in this order:
|
||||
| `ticks = n`, `frames = n` | that many ticks (the game's tick counter and the clock move on), then frames 1/60 s apart |
|
||||
| `chat = "<Steve> hi"` | a chat line the player receives |
|
||||
| `command = "where north"` | the player types `/where north`; a command the mod doesn't own fails the step |
|
||||
| `break = { x = 1, y = 63, z = 0, state = "minecraft:stone" }`, `place = { ... }` | server mods: the player breaks or places that block |
|
||||
| `leave = "Alex"` | server mods: that player leaves |
|
||||
|
||||
A server mod starts with nobody on: `join = "Alex"` (after `reload` and `title-screen`) brings a
|
||||
player in at the defaults, in survival, with the id
|
||||
`00000000-0000-4000-8000-000000000001` for the first name that joined, `...2`
|
||||
for the second, the same id when a name joins again. `player`, `chat`,
|
||||
`command`, `break` and `place` are then that player's doing: the one named by
|
||||
`as = "Steve"`, or the first one on. `player` takes `game-mode` there, and the
|
||||
script's own `[player]` and `[clock]` are a client mod's.
|
||||
|
||||
Then `expect` checks what the mod did during the step; a key left out is not
|
||||
checked:
|
||||
@@ -298,6 +309,7 @@ checked:
|
||||
| `chat = ["..."]` | every chat line it showed, in order (`[]`: none) |
|
||||
| `feedback = "..."`, `error = "..."` | the command's answer, shown plain or in red |
|
||||
| `panel = ["..."]`, `corner = "top-left"` | its HUD panel's lines (`[]`: no panel) and corner |
|
||||
| `told = ["Alex: Welcome!"]`, `broadcast = ["..."]` | server mods: every `players.tell` (as `name: text`) and `players.broadcast`, in order |
|
||||
| `stopped = "panic"` | the mod was turned off, for a reason holding this text; without it, a mod that traps, panics or overruns fails the test |
|
||||
|
||||
Unknown keys are errors, so a typo never passes silently. The same runner is
|
||||
|
||||
Reference in New Issue
Block a user