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 ¶
- type Conn
- type Options
- type Window
- func (w *Window) Ack(n int)
- func (w *Window) AckAll()
- func (w *Window) Answered() int
- func (w *Window) CloseTab()
- func (w *Window) Detach()
- func (w *Window) Drawn() int
- func (w *Window) Errors() []string
- func (w *Window) Last() pty.Info
- func (w *Window) Link(u string)
- func (w *Window) Resize(cols, rows int)
- func (w *Window) Resume()
- func (w *Window) Screen() string
- func (w *Window) States() []pty.Info
- func (w *Window) Type(s string)
- func (w *Window) Until(ok func() bool, d time.Duration, why func() string) error
- func (w *Window) WaitFor(text string, d time.Duration) error
- func (w *Window) WaitState(st pty.State, d time.Duration) (pty.Info, error)
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.
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) AckAll ¶
func (w *Window) AckAll()
AckAll acks everything drawn so far and acks from now on.
func (*Window) Resume ¶
func (w *Window) Resume()
Resume starts reading the stream of a window opened Paused.