docs: add replay-based automated testing design
Browse filesDesign for launching WA.exe with replay files for automated
validation and RE discovery. Validator DLL detects automated mode
via OPENWA_REPLAY_TEST env var and self-terminates after capture.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
docs/plans/2026-03-07-replay-testing-design.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Replay-Based Automated Testing Design
|
| 2 |
+
|
| 3 |
+
**Date:** 2026-03-07
|
| 4 |
+
**Status:** Approved
|
| 5 |
+
|
| 6 |
+
## Problem
|
| 7 |
+
|
| 8 |
+
The current validation workflow is manual: start WA.exe, navigate menus, start a game, press F9/F10 hotkeys, read logs. This is slow and non-reproducible. We need an automated way to launch the game into a known gameplay state for validation and RE discovery.
|
| 9 |
+
|
| 10 |
+
## Key Insight
|
| 11 |
+
|
| 12 |
+
WA.exe accepts a replay file (`.WAgame`) as a command-line argument. It starts playing automatically, skipping menus, and closes when the replay finishes. This gives us a deterministic, automated path into gameplay state.
|
| 13 |
+
|
| 14 |
+
## Design
|
| 15 |
+
|
| 16 |
+
### Components
|
| 17 |
+
|
| 18 |
+
#### 1. PowerShell script (`replay-test.ps1`)
|
| 19 |
+
|
| 20 |
+
Orchestrates the full workflow:
|
| 21 |
+
|
| 22 |
+
1. Build both DLLs (`cargo build --release -p openwa-wormkit -p openwa-validator`)
|
| 23 |
+
2. Deploy to game directory (same as `deploy.ps1`)
|
| 24 |
+
3. Clear old `OpenWA_validation.log` and `OpenWA.log` in game directory
|
| 25 |
+
4. Set `OPENWA_REPLAY_TEST=1` in environment
|
| 26 |
+
5. Launch `WA.exe <replay-file>` and wait for process exit
|
| 27 |
+
6. Copy both log files to `testdata/logs/` in the project
|
| 28 |
+
7. Print summary (PASS/FAIL counts from log)
|
| 29 |
+
|
| 30 |
+
Accepts one argument: replay file path. Defaults to `testdata/replays/bots.WAgame`.
|
| 31 |
+
|
| 32 |
+
#### 2. Validator DLL changes (`openwa-validator`)
|
| 33 |
+
|
| 34 |
+
At startup in `run_validation()`, check `std::env::var("OPENWA_REPLAY_TEST")`:
|
| 35 |
+
|
| 36 |
+
- **Not set:** Current behavior (deferred timer threads, hotkey listener, runs indefinitely).
|
| 37 |
+
- **Set:** Spawn a single "auto-capture" thread that:
|
| 38 |
+
1. Waits 30 seconds (enough for replay to reach gameplay)
|
| 39 |
+
2. Runs `deferred_global_validation()`
|
| 40 |
+
3. Runs `dump_team_blocks()`
|
| 41 |
+
4. Runs `dump_landscape()`
|
| 42 |
+
5. Logs `"--- Auto-capture complete, exiting ---"`
|
| 43 |
+
6. Calls `ExitProcess(0)` to terminate WA.exe
|
| 44 |
+
|
| 45 |
+
No hotkey listener or timer threads in automated mode -- one clean capture sequence.
|
| 46 |
+
|
| 47 |
+
#### 3. Claude Code skill (`replay-test`)
|
| 48 |
+
|
| 49 |
+
A skill that:
|
| 50 |
+
- Invokes `replay-test.ps1` via Bash
|
| 51 |
+
- Reads the resulting log files from `testdata/logs/`
|
| 52 |
+
- Presents results in the conversation
|
| 53 |
+
|
| 54 |
+
### Data Flow
|
| 55 |
+
|
| 56 |
+
```
|
| 57 |
+
/replay-test
|
| 58 |
+
-> Bash: powershell -File replay-test.ps1 testdata/replays/bots.WAgame
|
| 59 |
+
-> cargo build --release
|
| 60 |
+
-> deploy DLLs to game dir
|
| 61 |
+
-> clear logs
|
| 62 |
+
-> set OPENWA_REPLAY_TEST=1
|
| 63 |
+
-> start WA.exe bots.WAgame (blocks until exit)
|
| 64 |
+
-> validator DLL starts
|
| 65 |
+
-> detects env var -> auto-capture mode
|
| 66 |
+
-> waits 30s -> dumps -> ExitProcess(0)
|
| 67 |
+
-> WA.exe exits
|
| 68 |
+
-> copy logs to testdata/logs/
|
| 69 |
+
-> print summary
|
| 70 |
+
-> Skill reads testdata/logs/*.log
|
| 71 |
+
-> presents to user
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### File Locations
|
| 75 |
+
|
| 76 |
+
| File | Location |
|
| 77 |
+
|------|----------|
|
| 78 |
+
| Orchestration script | `replay-test.ps1` (project root) |
|
| 79 |
+
| Replay files | `testdata/replays/*.WAgame` |
|
| 80 |
+
| Captured logs | `testdata/logs/` (gitignored) |
|
| 81 |
+
| Skill definition | User's Claude Code skills directory |
|
| 82 |
+
|
| 83 |
+
### Environment Variable
|
| 84 |
+
|
| 85 |
+
| Variable | Value | Effect |
|
| 86 |
+
|----------|-------|--------|
|
| 87 |
+
| `OPENWA_REPLAY_TEST` | `1` | Validator enters auto-capture mode: single 30s wait, dump all, ExitProcess |
|
| 88 |
+
| (unset) | -- | Normal interactive mode with hotkeys and timer threads |
|
| 89 |
+
|
| 90 |
+
## Future Expansion (Not In Scope)
|
| 91 |
+
|
| 92 |
+
- Configurable wait time or dump selection via env vars or config file
|
| 93 |
+
- Event-based hooks (dump on CreateExplosion, WeaponRelease, etc.)
|
| 94 |
+
- Frame-count triggers via ProcessFrame hook
|
| 95 |
+
- Structured output (JSON) for programmatic diffing
|
| 96 |
+
- Multiple replay files in one run
|
| 97 |
+
- CI integration with exit codes based on PASS/FAIL counts
|