Documentation ¶
Overview ¶
Package termtest provides utilities for testing terminal-based programs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTerm ¶
func WithTerm() (exitCode int)
WithTerm is an entry point for a command line program "with-term". Its usage is as follows:
with-term [options] script -- cmd [args ...]
It runs cmd with the given arguments inside a terminal emulator, using the script file to drive interactions with it.
The file contains a series of newline delimited commands.
await Enter a name feed Foo\r snapshot
The following commands are supported.
- await [txt]: Wait up to 1 second for the given text to become visible on the screen. If [txt] is absent, wait until contents of the screen change compared to the last captured snapshot or last await empty.
- clear: Ignore current screen contents when awaiting text.
- snapshot [name]: Take a picture of the screen as it is right now, and print it to stdout. If name is provided, the output will include that as a header.
- feed txt: Feed the given string into the terminal. Go string-style escape codes are permitted without quotes. Examples: \r, \x1b[B
The following options may be provided before the script file.
- -cols int: terminal width (default 80)
- -rows int: terminal height (default 40)
- -final <name>: print a final snapshot on exit to stdout with the given name.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.