# tests ```sh ./scripts/test.sh # from the repo root - the supported way ``` Everything runs in the image's `test` stage, so the only requirement on your machine is Docker, and the tests see exactly the JDK, MegaMek jar and shell that the build does. The stage either passes or the build fails; nothing is tagged. | group | what it checks | |---|---| | `lint` | shellcheck, following `source` into `container/lib/common.sh` | | `syntax` | every `.sh` parses; the JSON and XML templates parse | | `unit` | the container's shell logic against fixtures | | `compile` | `src/` and `tests/src/` compile against the stock MegaMek jar, and the patched jar differs from stock in exactly the patched classes | ## What the unit tests cover - `test-manifest-validation.sh` — the init scripts reject a malformed launch manifest and say why: unknown version, missing `matchId`, a scenario with no digest, expired, duplicate slots, a human with no DID, no humans at all. These are the container's only defence against a bad launch. - `test-render-config.sh` — the Suramadu config renders with no `@PLACEHOLDER@` left behind. An unsubstituted player name means a client that logs in as `@PLAYER_NAME@` and sits in the lobby forever. - `test-perf-shim.sh` — `suramadu/web/perf.js`, the latency instrument served to every player. That it parses (bracket balance; `node --check` too if the machine has node), that nothing is installed above its `?perf=1` check, that its ring buffer is bounded, that `window.__arenaPerf` still exposes what a headless pilot calls, and that `index.html` loads it after `suramadu-init.js` under an unchanged CSP. - `test-profiling.sh` — the profiler is off unless `ARENA_PROFILE` is set, and off means the client JVM's `vmArgs` render exactly as they did before it existed. Also that the async-profiler pins in `versions.env` and the Dockerfile's defaults agree, and that finalize reduces Suramadu's `stats,` lines into a table. - `test-deploy.sh` — what `scripts/deploy.sh` refuses. It writes the release id production is pinned to, so the guards in front of it are the whole point: a dirty tree, and a main that has drifted from `origin/main` either way. Builds throwaway git repositories, which is why the test stage installs `git`; it never builds or pushes anything. - `test-arena.sh` — the decisions `scripts/arena.sh` makes around the daemon: the resource caps and their clamping, which containers count as arena's given fake `docker ps` rows, what the argument parser refuses, and that a start which never serves fails loudly and cleans up. `docker` and `curl` are stubbed on PATH and `DOCKER_HOST` points at nothing, so no container is ever started. - `test-image.sh` — how `scripts/image.sh` picks an image: the commit parsed out of a tag, the selectors that name a build, and what it refuses when a selector matches nothing or matches two. A stub `docker` serves a fixture table of tags, so there is no daemon here; the git side is a throwaway repository, because choosing between builds made in the same second is a git question. ## Not run by default - `bench.sh` — the density benchmark. Takes minutes and wants a quiet machine. It answers a product question (how many matches fit on a box) rather than gating a change. `summarize.py` reduces its CSV; `heap-sweep.sh` runs it across a range of heap caps. - `module-scan.py` — reports JDK modules the shipped jars reference that the jlink runtime omits. Run it after bumping MegaMek or Suramadu; a missing module does not fail the build, it fails at runtime far from the cause. Reports rather than passes or fails. - `profile-summary.py` — reduces an async-profiler collapsed file to the EDT's share of the work. Wall-clock sampling records every parked thread, so a raw read of a profile is mostly threads doing nothing; this separates the EDT's waiting from its running and buckets the running part into paint, DirectDraw and PNG encode. `tests/shell/test-profile-summary.sh` covers it against a fixture, and does run by default. - `screenshot.py` — drives a headless Chrome over CDP to screenshot a running match. How the glyph and layout work was verified. Needs a Chrome already listening on `--remote-debugging-port`.