The six termtris test drivers are near-identical copies of the loader harness, and a change to the shared machinery has to be made six times.
Evidence (head 58f8f44)
file
lines
apps/termtris/tests/smoke.lua
355
apps/termtris/tests/fmt.lua
354
apps/termtris/tests/render.lua
347
apps/termtris/tests/input.lua
387
apps/termtris/tests/play.lua
350
apps/termtris/tests/play_keys.lua
390
total
2183
Each copy shares almost everything:
all six diverge from smoke.lua at line 28 (the ports/keys block) and reconverge;
compared with smoke.lua, every other file has only 7-46 unique lines (only 11-16 of smoke.lua's own lines are unique against any one of them);
the COFF poking, descriptor setup, create_process entry, result polling and exit logic is copied verbatim from dwt/loader/loader.lua (338 lines);
the copies still carry the header -- loader.lua -- debugger-assisted COFF loader acceptance harness., even though each now has test-specific hooks at the bottom.
play.lua has already diverged in its result format (DIAG: tick=... quit=...) from play_keys.lua (DIAG: loops=... events=... last=... focus=... rev=... quit=...), which is the first symptom of six independent copies.
Proposal
Extract the shared loader/COFF/debugger machinery into one module, e.g. apps/termtris/tests/harness.lua, and make each test a thin configuration + hooks file:
configuration: LOADER_AT, LOADER_END, snapshot flag, ports/keys it needs;
Keep every tests/*.sh and its environment contract unchanged. dwt/loader/loader.lua can stay as the reference for the general loader milestones; the termtris tests should not fork it.
Acceptance
apps/termtris/verify.sh --skip-mame still reports verify: PASS with the same DIAG values and regenerated evidence.
The six test files lose roughly 1800 lines; the shared part exists once.
At minimum, the result output is one format shared by play.lua and play_keys.lua.
This is a follow-up to PR #5, not a blocker for it.
The six termtris test drivers are near-identical copies of the loader harness, and a change to the shared machinery has to be made six times.
## Evidence (head `58f8f44`)
| file | lines |
|---|---:|
| `apps/termtris/tests/smoke.lua` | 355 |
| `apps/termtris/tests/fmt.lua` | 354 |
| `apps/termtris/tests/render.lua` | 347 |
| `apps/termtris/tests/input.lua` | 387 |
| `apps/termtris/tests/play.lua` | 350 |
| `apps/termtris/tests/play_keys.lua` | 390 |
| **total** | **2183** |
Each copy shares almost everything:
- all six diverge from `smoke.lua` at line 28 (the ports/keys block) and reconverge;
- compared with `smoke.lua`, every other file has only **7-46 unique lines** (only 11-16 of `smoke.lua`'s own lines are unique against any one of them);
- the COFF poking, descriptor setup, `create_process` entry, result polling and exit logic is copied verbatim from `dwt/loader/loader.lua` (338 lines);
- the copies still carry the header `-- loader.lua -- debugger-assisted COFF loader acceptance harness.`, even though each now has test-specific hooks at the bottom.
`play.lua` has already diverged in its result format (`DIAG: tick=... quit=...`) from `play_keys.lua` (`DIAG: loops=... events=... last=... focus=... rev=... quit=...`), which is the first symptom of six independent copies.
## Proposal
Extract the shared loader/COFF/debugger machinery into one module, e.g. `apps/termtris/tests/harness.lua`, and make each test a thin configuration + hooks file:
- configuration: `LOADER_AT`, `LOADER_END`, snapshot flag, ports/keys it needs;
- hooks: `on_frame(frames)`, `result_dump()`, `on_done(status)`;
- shared code: COFF parsing, loader placement, `create_process`, status polling, snapshot, exit.
Keep every `tests/*.sh` and its environment contract unchanged. `dwt/loader/loader.lua` can stay as the reference for the general loader milestones; the termtris tests should not fork it.
## Acceptance
- `apps/termtris/verify.sh --skip-mame` still reports `verify: PASS` with the same DIAG values and regenerated evidence.
- The six test files lose roughly 1800 lines; the shared part exists once.
- At minimum, the result output is one format shared by `play.lua` and `play_keys.lua`.
This is a follow-up to PR #5, not a blocker for it.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The six termtris test drivers are near-identical copies of the loader harness, and a change to the shared machinery has to be made six times.
Evidence (head
58f8f44)apps/termtris/tests/smoke.luaapps/termtris/tests/fmt.luaapps/termtris/tests/render.luaapps/termtris/tests/input.luaapps/termtris/tests/play.luaapps/termtris/tests/play_keys.luaEach copy shares almost everything:
smoke.luaat line 28 (the ports/keys block) and reconverge;smoke.lua, every other file has only 7-46 unique lines (only 11-16 ofsmoke.lua's own lines are unique against any one of them);create_processentry, result polling and exit logic is copied verbatim fromdwt/loader/loader.lua(338 lines);-- loader.lua -- debugger-assisted COFF loader acceptance harness., even though each now has test-specific hooks at the bottom.play.luahas already diverged in its result format (DIAG: tick=... quit=...) fromplay_keys.lua(DIAG: loops=... events=... last=... focus=... rev=... quit=...), which is the first symptom of six independent copies.Proposal
Extract the shared loader/COFF/debugger machinery into one module, e.g.
apps/termtris/tests/harness.lua, and make each test a thin configuration + hooks file:LOADER_AT,LOADER_END, snapshot flag, ports/keys it needs;on_frame(frames),result_dump(),on_done(status);create_process, status polling, snapshot, exit.Keep every
tests/*.shand its environment contract unchanged.dwt/loader/loader.luacan stay as the reference for the general loader milestones; the termtris tests should not fork it.Acceptance
apps/termtris/verify.sh --skip-mamestill reportsverify: PASSwith the same DIAG values and regenerated evidence.play.luaandplay_keys.lua.This is a follow-up to PR #5, not a blocker for it.