Documentation
¶
Overview ¶
Package expect implements a small expect-style interface
Index ¶
- Variables
- type Process
- func (ep *Process) Close() error
- func (ep *Process) ExitCode() (int, error)
- func (ep *Process) ExitError() error
- func (ep *Process) Expect(s string) (string, error)
- func (ep *Process) ExpectFunc(ctx context.Context, f func(string) bool) (string, error)
- func (ep *Process) ExpectWithContext(ctx context.Context, s Response) (string, error)
- func (ep *Process) LineCount() int
- func (ep *Process) Lines() []string
- func (ep *Process) PID() int
- func (ep *Process) ReadLine() string
- func (ep *Process) Send(command string) error
- func (ep *Process) Signal(sig os.Signal) error
- func (ep *Process) Stop() error
- func (ep *Process) Wait()
- type Response
Constants ¶
This section is empty.
Variables ¶
var (
ErrProcessRunning = errors.New("process is still running")
)
Functions ¶
This section is empty.
Types ¶
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
func NewWithEnv ¶
func NewWithEnv(name string, args []string, env []string, serverProcessConfigName string) (ep *Process, err error)
NewWithEnv creates a new process with user defined env variables for expect testing.
func (*Process) ExitCode ¶
ExitCode returns the exit code of this process. If the process is still running, it returns exit code 0 and ErrProcessRunning.
func (*Process) ExitError ¶
ExitError returns the exit error of this process (if any). If the process is still running, it returns ErrProcessRunning instead.
func (*Process) Expect ¶
Expect returns the first line containing the given string. Deprecated: please use ExpectWithContext instead.
func (*Process) ExpectFunc ¶
ExpectFunc returns the first line satisfying the function f.
func (*Process) ExpectWithContext ¶
ExpectWithContext returns the first line containing the given string.
func (*Process) LineCount ¶
LineCount returns the number of recorded lines since the beginning of the process.