expect

package
v3.0.0-...-eac99ac Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package expect implements a small expect-style interface TODO(ptab): Consider migration to https://github.com/google/goexpect.

Index

Constants

View Source
const DEBUG_LINES_TAIL = 40

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpectProcess

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

func NewExpect

func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error)

NewExpect creates a new process for expect testing.

func NewExpectWithEnv

func NewExpectWithEnv(name string, args []string, env []string, serverProcessConfigName string) (ep *ExpectProcess, err error)

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. Close currently does not return error if process exited with !=0 status. TODO: Close should expose underlying process failure by default.

func (*ExpectProcess) Expect

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

Expect returns the first line containing the given string. Deprecated: please use ExpectWithContext instead.

func (*ExpectProcess) ExpectFunc

func (ep *ExpectProcess) ExpectFunc(ctx context.Context, f func(string) bool) (string, error)

ExpectFunc returns the first line satisfying the function f.

func (*ExpectProcess) ExpectWithContext

func (ep *ExpectProcess) ExpectWithContext(ctx context.Context, s string) (string, error)

ExpectWithContext returns the first line containing the given string.

func (*ExpectProcess) LineCount

func (ep *ExpectProcess) LineCount() int

LineCount returns the number of recorded lines since the beginning of the process.

func (*ExpectProcess) Lines

func (ep *ExpectProcess) Lines() []string

func (*ExpectProcess) Pid

func (ep *ExpectProcess) Pid() int

func (*ExpectProcess) ProcessError

func (ep *ExpectProcess) ProcessError() error

func (*ExpectProcess) ReadLine

func (ep *ExpectProcess) ReadLine() string

ReadLine returns line by 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) Stop

func (ep *ExpectProcess) Stop() error

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

Jump to

Keyboard shortcuts

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