Documentation
¶
Overview ¶
Real terminal emulators under a private Xvfb display running icebath, driven by injected input and judged by screenshots
Index ¶
- Constants
- Variables
- func Coverage(img image.Image, r image.Rectangle, bg color.Color) float64
- func DiffBounds(a, b image.Image, r image.Rectangle) image.Rectangle
- func Differs(a, b image.Image, r image.Rectangle) float64
- func Icebath() (string, error)
- func Limited(bytes uint64, argv ...string) (*exec.Cmd, error)
- func Line(cells []string) string
- func Missing(tools ...string) error
- func MouseSeq(x, y, button int, press bool) []byte
- func RemoveBuild() error
- func RunHelper()
- func Sample(img image.Image, rects []image.Rectangle) []color.RGBA
- func SavePNG(path string, img image.Image) error
- func Uniform(img image.Image, r image.Rectangle) bool
- func WriteConfig(dir string, settings map[string]string) error
- type Chunk
- type Emulator
- type Lab
- type Program
- type Session
- func (s *Session) Cells(col, row, w, h int) image.Rectangle
- func (s *Session) Chunks() []Chunk
- func (s *Session) Close() error
- func (s *Session) Ended() string
- func (s *Session) Find(text string) (col, row int, ok bool)
- func (s *Session) Grid() [][]uv.Cell
- func (s *Session) Input() []Chunk
- func (s *Session) Key(seq []byte) (time.Time, error)
- func (s *Session) Latency(timeout time.Duration) (time.Duration, error)
- func (s *Session) Mouse(x, y, button int, press bool) (time.Time, error)
- func (s *Session) Output() []byte
- func (s *Session) Pitch() (float64, float64)
- func (s *Session) Screen() [][]string
- func (s *Session) Shot() (*image.RGBA, error)
- func (s *Session) ShotOf(region image.Rectangle) (*image.RGBA, error)
- func (s *Session) Size() (cols, rows int)
- func (s *Session) Type(keys string) (time.Time, error)
- func (s *Session) WaitChange(from image.Image, region image.Rectangle, timeout time.Duration) (*image.RGBA, error)
- func (s *Session) WaitFor(cond func([]byte) bool, timeout time.Duration) error
- func (s *Session) Watch(box image.Rectangle) *Watch
- func (s *Session) Write(b []byte) (time.Time, error)
- type Watch
Constants ¶
const BinaryEnv = "TERMLAB_ICEBATH"
Environment variable naming a prebuilt icebath binary the tests run instead of building one
const BuildLimit = 12000000 * 1024
Address space limit of builds, the 12000000 KiB of ulimit -v the project builds under
const BuildMemLimit = "4GiB"
Soft heap limit of the Go toolchain during builds
const DriverEnv = "TERMLAB_DRIVER"
Environment variable naming the unix socket a driver serves
const ProbeEnv = "TERMLAB_PROBE"
Environment variable that turns the test binary into the probe program the rig checks itself with
Variables ¶
var Konsole = Emulator{Name: "konsole", /* contains filtered or unexported fields */}
KDE terminal without its menu and tab bars at 160 by 48 cells
var Xterm = Emulator{Name: "xterm", /* contains filtered or unexported fields */}
X terminal emulating a vt340 so it draws sixel, at 160 by 48 cells
Functions ¶
func DiffBounds ¶
Bounding box of the pixels inside the rectangle that differ between the two images
func Icebath ¶
Builds cmd/icebath once per test binary under the project memory limits, or takes the prebuilt binary named
func Limited ¶
Command running argv under the address space limit, through this test binary as the limiting helper
func MouseSeq ¶
SGR 1006 bytes of a mouse press or release, button 0 left, 1 middle, 2 right, 64 and 65 wheel
func RunHelper ¶
func RunHelper()
Runs the driver, the probe or a memory limited command when the environment asks for one, returns at once otherwise
Types ¶
type Emulator ¶
type Emulator struct {
Name string
// contains filtered or unexported fields
}
Terminal emulator a session runs in, with the command line that runs a program inside it
type Lab ¶
Private X display served by Xvfb, its framebuffer kept in a file the lab reads screenshots from
func Start ¶
Starts Xvfb with a w by h screen on the first display number holding no socket or lock file
func (*Lab) Close ¶
Stops the X server, asking first so it removes its socket and lock, then killing it, and deletes its framebuffer
func (*Lab) Open ¶
Starts the emulator on the display running the test binary as driver, calibrates the cell grid and starts the program
type Program ¶
Command the driver starts on its pseudo terminal, Env laid over the environment the emulator gave the driver
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Program running in an emulator on a lab display, reached through the driver socket, with the cell geometry calibration found
func (*Session) Cells ¶
Pixel rectangle of the screen covering w by h cells from the zero based column and row
func (*Session) Close ¶
Stops polling and kills the emulator with the driver and the program under it
func (*Session) Find ¶
Zero based column and row where the text starts on the mirrored screen, false when it is not there
func (*Session) Grid ¶
Cells of the screen as the program painted them, read from a mirror emulator fed the same output
func (*Session) Input ¶
What the emulator sent the program, key presses and query answers, in the pieces the driver read
func (*Session) Latency ¶
Time from the last injected write to the next program output, failing when none arrives within the timeout
func (*Session) Mouse ¶
Sends an SGR 1006 mouse press or release of a button at the one based column x and row y
func (*Session) Output ¶
Everything the program wrote so far, a view that later output never changes
func (*Session) Screen ¶
Text of each mirrored cell, a space for a blank cell and empty for the tail of a wide one
func (*Session) WaitChange ¶
func (s *Session) WaitChange(from image.Image, region image.Rectangle, timeout time.Duration) (*image.RGBA, error)
Takes screenshots until the region differs from the given one, returning the first that does
func (*Session) WaitFor ¶
Waits until the output satisfies the condition, failing at the timeout or when the program ends first
type Watch ¶
type Watch struct {
// contains filtered or unexported fields
}
Recorder of every change to a box of mirrored cells, stamped with the read time of the output causing it
func (*Watch) Answer ¶
Read time of the first chunk after the moment leaving at least the share of cells changed from that moment