P0.4: wire the logic verification gate (sx assert helper + snapshot runner)
Add a real logic-test gate so future pure-sx game logic fails the build on a bad assertion: - tests/test.sx: `expect(cond, msg)` assert helper — prints a greppable `FAIL <file>:<line>: <msg>` and exits non-zero via process.exit on failure. - tools/run_tests.sh: snapshot runner mirroring sx/tests/run_examples.sh; runs each tests/<name>.sx and diffs stdout + exit code against tests/expected/. Exits 0 iff all tests pass. - tests/arith.sx (+ expected snapshots): seed passing sanity test. - README.md: document both halves of the gate — logic runner and the reproducible ios-sim build/launch sequence (with device discovery).
This commit is contained in:
50
README.md
50
README.md
@@ -7,3 +7,53 @@ A match-3 game written entirely in the **sx** language, targeting **iOS** first.
|
||||
- Verification gate: sx logic tests pass AND the iOS app builds & launches in the Simulator.
|
||||
|
||||
Development is driven by the multi-agent `flow` (Product Owner → Worker → Reviewer → Observer).
|
||||
|
||||
## Verification gate
|
||||
|
||||
The gate has two halves. Both must pass. The sx compiler used below lives at
|
||||
`/Users/agra/projects/sx/zig-out/bin/sx` (override the runner's binary with the
|
||||
`SX` env var). Run everything from the repo root.
|
||||
|
||||
### 1. Logic tests
|
||||
|
||||
Pure-sx logic tests run under `sx` and have their stdout + exit code diffed
|
||||
against committed snapshots in `tests/expected/`. A failed assertion exits the
|
||||
process non-zero, so it fails the runner (and the gate).
|
||||
|
||||
```bash
|
||||
bash tools/run_tests.sh
|
||||
```
|
||||
|
||||
- A test is any `tests/<name>.sx` that has a `tests/expected/<name>.exit`
|
||||
marker; `tests/test.sx` (the `expect` assert helper) has no marker, so it is
|
||||
not itself run.
|
||||
- Regenerate snapshots after an intentional change: `bash tools/run_tests.sh --update`.
|
||||
|
||||
### 2. iOS Simulator build + launch
|
||||
|
||||
Build the app for the simulator, then install/launch it on an available device
|
||||
and screenshot the rendered scene (blue background + a centered orange quad).
|
||||
|
||||
```bash
|
||||
# Build the .app bundle (sx-out/ios/M3te.app):
|
||||
/Users/agra/projects/sx/zig-out/bin/sx build --target ios-sim main.sx
|
||||
|
||||
# Discover an available simulator — do NOT hardcode a udid:
|
||||
xcrun simctl list devices available
|
||||
# e.g. capture the first available device's UDID into $udid:
|
||||
udid=$(xcrun simctl list devices available | grep -Eo '[0-9A-Fa-f-]{36}' | head -1)
|
||||
|
||||
# Boot it (skip if already "Booted") and bring the Simulator window up:
|
||||
xcrun simctl boot "$udid" || true
|
||||
open -a Simulator
|
||||
|
||||
# Install, launch (bundle id co.swipelab.m3te), and screenshot:
|
||||
xcrun simctl install booted sx-out/ios/M3te.app
|
||||
xcrun simctl launch booted co.swipelab.m3te
|
||||
xcrun simctl io booted screenshot /tmp/m3te.png
|
||||
```
|
||||
|
||||
The screenshot should match `goldens/p0_quad.png` (a centered orange quad over a
|
||||
blue clear), modulo the status-bar clock — pixel-exact equality is not required.
|
||||
A tap on the quad flips its color (orange ↔ green); see
|
||||
`goldens/p0_input_before.png` / `goldens/p0_input_after.png`.
|
||||
|
||||
Reference in New Issue
Block a user