Documentation
¶
Overview ¶
Package engine runs flows on a device, around device events.
Waiting never polls the device. An element lookup reads the screen once; if the element is not there it sleeps until the agent pushes "the UI changed and settled" (or keeps changing for longer than a frame budget), then reads again. A screen read is reused for as long as the device reports no change since.
Index ¶
- func Describe(c *flow.Command) string
- type CSSQuerier
- type DarkModer
- type Event
- type FlowError
- type FlowResult
- type NotFound
- type Options
- type Reporter
- type ReporterFunc
- type Runner
- func (r *Runner) Begin(f *flow.Flow, extraEnv []flow.KV) error
- func (r *Runner) End()
- func (r *Runner) LastScreen() *ui.Screen
- func (r *Runner) RunCommands(ctx context.Context, cmds []*flow.Command, appID string, ...) error
- func (r *Runner) RunFlow(ctx context.Context, f *flow.Flow) (res FlowResult)
- func (r *Runner) RunList(ctx context.Context, cmds []*flow.Command, f *flow.Flow) error
- func (r *Runner) SetAppID(id string)
- func (r *Runner) SetEnv(kvs []flow.KV) error
- type Signals
- type Status
- type StepResult
- type Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CSSQuerier ¶
CSSQuerier is a driver that can evaluate CSS selectors (web).
type DarkModer ¶
type DarkModer interface {
SetDarkMode(ctx context.Context, on bool) error
DarkMode(ctx context.Context) (bool, error)
}
DarkModer is implemented by drivers that can read and set the system appearance.
type Event ¶
type Event struct {
Device string // role or device name (multi-device runs)
Cmd *flow.Command
Desc string
Depth int
Start bool
Status Status
Err error
Elapsed time.Duration
Log string // console.log or diagnostic line
}
Event tells a Reporter about progress.
type FlowError ¶
type FlowError struct{ Msg string }
FlowError is a test failure an optional command downgrades to a warning (element not found, assertion false, ...).
type FlowResult ¶
type FlowResult struct {
Name string
File string
Status Status
Err error
Duration time.Duration
Steps []StepResult
}
FlowResult is the outcome of one flow.
type Options ¶
type Options struct {
Env []flow.KV // -e values and injected TB_ variables, in order
LookupTimeout time.Duration // default 17 s
OptionalTimeout time.Duration // default 7 s
ArtifactsDir string // where takeScreenshot/startRecording write ("" = cwd)
Reporter Reporter
Role string // device role in a multi-device flow
Signals *Signals
JS *js.Engine // shared engine (multi-device); nil = a new one per flow
Trace *Trace // the run's step-by-step log (trace.go); nil = none
}
Options configure a Runner.
type Reporter ¶
type Reporter interface{ Event(Event) }
Reporter receives events. Implementations must be safe for concurrent use.
type ReporterFunc ¶
type ReporterFunc func(Event)
func (ReporterFunc) Event ¶
func (f ReporterFunc) Event(e Event)
type Runner ¶
Runner runs commands on one device.
func (*Runner) Begin ¶
Begin prepares a flow run without running commands (multi-device flows drive each device's command lists themselves). extraEnv (a role's env) comes after the CLI env and the flow's, so it wins.
func (*Runner) LastScreen ¶
LastScreen is the most recent read (for failure reports).
func (*Runner) RunCommands ¶
func (r *Runner) RunCommands(ctx context.Context, cmds []*flow.Command, appID string, onStep func(StepResult)) error
RunCommands runs loose commands (an agent's `tb do`) with the flow context of appID.
func (*Runner) RunFlow ¶
RunFlow runs a flow file from the start: env, onFlowStart, commands, onFlowComplete.
func (*Runner) RunList ¶
RunList runs commands in the current flow context, stopping at the first failure.
type Signals ¶
type Signals struct {
// contains filtered or unexported fields
}
Signals lets devices in a multi-device flow wait for each other: one device runs `signal: sent`, another `waitForSignal: sent`. Waiting is a channel close, not a poll.
func NewSignals ¶
func NewSignals() *Signals
type StepResult ¶
StepResult is one top-level command's outcome.