Documentation
¶
Overview ¶
Command wincons drives the example app (./_examples/cliapp) on a real Windows console: the Windows twin of scripts/ptysmoke (PTY, Linux/macOS only).
Python's pty module does not exist on Windows, and a ConPTY child cannot be started from a gofer job (CreateProcess with PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE fails with 0xC0000142 there), so this harness drives the console Windows has: it detaches from the console it was started with, creates a private one (AllocConsole), starts the app with that console's CONIN$ as stdin and its stdout/stderr on a pipe, then types the answer as KEY_EVENT records with WriteConsoleInput - exactly what a keyboard writes into the console input buffer. The app therefore sees a genuine console on stdin (cooked line input, the prompt is real), while the harness can still read what it printed.
go build -o tmp/wincons/cliapp.exe ./_examples/cliapp go run ./scripts/wincons --bin tmp/wincons/cliapp.exe
Every case is independent: it gets a fresh console, so no stale key event can leak into the next one. Exit status 0 when every check passes.