ptytest

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ptytest is a tab's window for tests: it connects to a tab through pty.Serve over an in-memory stream, draws the output in a terminal emulator (charmbracelet/x/vt) that answers the program's queries as xterm.js does in the app, acks what it drew, and types what the test types (as the user would; hopsesh never does).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is an in-memory stream: Send hands a frame to the window (blocking while Depth frames wait, like a Wails stream's bounded buffer), Receive takes the window's next frame.

func NewConn

func NewConn(depth int) *Conn

NewConn is a stream holding at most depth frames for the window.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Context

func (c *Conn) Context() context.Context

func (*Conn) Receive

func (c *Conn) Receive() ([]byte, error)

func (*Conn) Send

func (c *Conn) Send(f []byte) error

type Options

type Options struct {
	Cols, Rows int
	// Depth is how many frames the stream holds for the window (0: 256).
	Depth int
	// NoAck: the window draws but never acks (until Ack).
	NoAck bool
	// Paused: the window does not read the stream until Resume.
	Paused bool
}

Options shape a Window.

type Window

type Window struct {
	Conn *Conn
	// Served is Serve's result once it returned.
	Served chan error
	// contains filtered or unexported fields
}

Window is a tab's window.

func Open

func Open(find func(string) (*pty.Session, error), openLink func(string), id string, o Options) *Window

Open attaches a window to tab id, served by find (and openLink for links).

func (*Window) Ack

func (w *Window) Ack(n int)

Ack says n more bytes were drawn.

func (*Window) AckAll

func (w *Window) AckAll()

AckAll acks everything drawn so far and acks from now on.

func (*Window) Answered

func (w *Window) Answered() int

Answered is how many replies to queries the emulator sent.

func (*Window) CloseTab

func (w *Window) CloseTab()

CloseTab asks hopsesh to close the tab.

func (*Window) Detach

func (w *Window) Detach()

Detach is the window going away.

func (*Window) Drawn

func (w *Window) Drawn() int

Drawn is how many bytes of output the window drew.

func (*Window) Errors

func (w *Window) Errors() []string

Errors are the refusals hopsesh sent.

func (*Window) Last

func (w *Window) Last() pty.Info

Last is the last state hopsesh sent (zero before any).

func (w *Window) Link(u string)

Link asks hopsesh to open a link.

func (*Window) Resize

func (w *Window) Resize(cols, rows int)

Resize sends the window's new size (and resizes its emulator).

func (*Window) Resume

func (w *Window) Resume()

Resume starts reading the stream of a window opened Paused.

func (*Window) Screen

func (w *Window) Screen() string

Screen is what the emulator shows.

func (*Window) States

func (w *Window) States() []pty.Info

States are the states hopsesh sent, in order.

func (*Window) Type

func (w *Window) Type(s string)

Type sends keys, as the user types them.

func (*Window) Until

func (w *Window) Until(ok func() bool, d time.Duration, why func() string) error

Until polls ok for up to d.

func (*Window) WaitFor

func (w *Window) WaitFor(text string, d time.Duration) error

WaitFor waits until the screen shows text.

func (*Window) WaitState

func (w *Window) WaitState(st pty.State, d time.Duration) (pty.Info, error)

WaitState waits until hopsesh says the tab is in state st.

Jump to

Keyboard shortcuts

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