Test your program in its window
terse run tests what a program computes: the screen and the state hash after scripted keys, the same on every computer. It does not show what the window shows over time: the picture as drawn, keys as a keyboard sends them, a part that flickers. terse-host --drive does. It runs the program in the real window with input from a script, and checks what the window shows.
It never opens a window on your desktop: on Linux it starts a hidden display of its own (the compositor weston, which must be installed); on Windows and macOS it refuses. It runs the built .terse file, so it is the same for C and Rust programs. Here it tests line.terse, the program of "Draw a line and read a key".
The script
line.drive:
settle expect vectors contains line 5120 6400 5120 1280 shot start.png press left press left settle expect vectors contains line 5120 6400 4800 1280 expect idle 30 shot left.png
One command a line, in order:
settlewaits until the picture stops changing.expect vectors containsfails unless the line display's list holds the rest of the line: here the line from (320, 400) to (320, 80), in sixteenths of a screen unit, asterse run --dump-vectorsprints it.shot start.pngsaves the picture as shown.press leftpresses and releases the Left key, as a keyboard does.expect idle 30fails if the picture changes in the next 30 frames: with no key pressed, nothing should move.
Run it
terse-host line.terse --drive line.drive --renderer software
frame 3-13: settle: 10 pictures, 0 changed,
settled (10 unchanged)
frame 14: ok: vectors contains "line 5120 6400 5120 1280"
frame 14: shot start.png (880x660)
frame 22-32: settle: 10 pictures, 0 changed,
settled (10 unchanged)
frame 33: ok: vectors contains "line 5120 6400 4800 1280"
frame 33-63: expect idle 30: 30 pictures, 0 changed
frame 63: ok: expect idle 30
frame 64: shot left.png (880x660)
drive: done, no expectation failed
Each line starts with the frame it looked at; the numbers vary a little from run to run, since the window runs in real time. (Two long lines are wrapped here.) The run ends with status 0, or 1 if an expectation failed: its line says FAIL: and what was there instead. start.png and left.png are the pictures. --renderer software draws without the graphics card, the same everywhere; leave it out to test the GPU's drawing.
The same script runs headless, terse run line.terse --events line.drive --frames 60 --dump --dump-vectors: it gives the keys and passes over the window's commands.
What you have now
A test that sees what the user sees. type, click, hold and resize give other input; dump page prints the page as laid out; expect no-slow fails if a frame was late. Every command is in Testing a program. Next, a bigger step: Make a host, step 1: run a program to its end.