visualtest

package
v0.0.0-...-0f1ffb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package visualtest captures the screen produced by an example program.

It composes programtest's in-process host with ptytest's renderer-sized screen model. The first drives the real program loop and captures its frame bytes; the second answers what those bytes leave in terminal cells. Keeping that composition here gives examples one visual assertion path instead of a private screen model in every command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(tb testing.TB, path string, rows []string)

Match compares the visible part of rows with the golden file at path. Running the example module's tests with -update replaces the file with the captured result.

Trailing spaces and blank rows carry no visible information and are removed. Spaces inside a row and empty rows between content remain significant.

Types

type Capture

type Capture struct {
	Rows     []string
	Encoding string
}

Capture is one completely repainted program screen and the renderer bytes that produced that repaint.

type Config

type Config struct {
	Width, Height int
	Ground        grid.Ground
}

Config is the complete initial state of a visual-test Host. Width and Height must be positive terminal-cell dimensions. The zero Ground models an unknown terminal background.

type Host

type Host struct {
	*programtest.Host
	// contains filtered or unexported fields
}

Host is a programtest host that also reports the terminal colours an example is being checked against. No other optional capability is invented.

func New

func New(tb testing.TB, config Config) *Host

New returns a visual host at size with the given terminal colours.

func (*Host) Capture

func (h *Host) Capture(tb testing.TB) Capture

Capture asks for a full repaint, waits for it to reach the host, and interprets every frame written so far as one terminal screen.

func (*Host) Ground

func (h *Host) Ground() grid.Ground

Ground reports the terminal colours used to build the example's theme.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL