expect

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 11 Imported by: 1

README

Expect - With Docker support

What is this?

Designed to run shell tests in Docker. Support Bash and Zsh.

License

MIT

Authors:

Documentation

Overview

Package expect implements a small expect-style interface

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommandExited  = errors.New("command exited")
	ErrAlreadyClosed  = errors.New("already closed")
	ErrProcessStopped = errors.New("process stopped")
)

Functions

This section is empty.

Types

type ExpectProcess

type ExpectProcess struct {

	// StopSignal is the signal Stop sends to the process; defaults to SIGKILL.
	StopSignal os.Signal

	// Debug enables some debug logs
	Debug bool
	// contains filtered or unexported fields
}

func NewExpect

func NewExpect(name string, arg ...string) *ExpectProcess

NewExpect creates a new process for expect testing.

func NewExpectWithEnv

func NewExpectWithEnv(name string, args []string, env []string) *ExpectProcess

NewExpectWithEnv creates a new process with user defined env variables for expect testing.

func (*ExpectProcess) Close

func (ep *ExpectProcess) Close() error

Close waits for the expect process to exit.

func (*ExpectProcess) Expect

func (ep *ExpectProcess) Expect(s string) (string, error)

Expect returns the first line containing the given string.

func (*ExpectProcess) ExpectFunc

func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error)

ExpectFunc returns the first line satisfying the function f.

func (*ExpectProcess) Line

func (ep *ExpectProcess) Line() (string, error)

Line returns one line.

func (*ExpectProcess) Send

func (ep *ExpectProcess) Send(command string) error

func (*ExpectProcess) Signal

func (ep *ExpectProcess) Signal(sig os.Signal) error

Signal sends a signal to the expect process

func (*ExpectProcess) Start

func (ep *ExpectProcess) Start() (err error)

func (*ExpectProcess) Stop

func (ep *ExpectProcess) Stop() error

Stop kills the expect process and waits for it to exit.

type ShellExpect

type ShellExpect struct {
	Debug bool
	// contains filtered or unexported fields
}

func NewShellExpect

func NewShellExpect(expect *ExpectProcess, prompt string) *ShellExpect

func (*ShellExpect) Init

func (c *ShellExpect) Init() error

Init synchronize the prompt detection by expecting the initial prompt.

func (*ShellExpect) Run

func (c *ShellExpect) Run(command string) ([]string, error)

Jump to

Keyboard shortcuts

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