cmdtest

package
v0.0.0-rc4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestCmd

type TestCmd struct {
	// For total convenience, all testing methods are available.
	*testing.T

	Func    template.FuncMap
	Data    interface{}
	Cleanup func()

	// Err will contain the process exit error or interrupt signal error
	Err error
	// contains filtered or unexported fields
}

func NewTestCmd

func NewTestCmd(t *testing.T, data interface{}) *TestCmd

func (*TestCmd) CloseStdin

func (tt *TestCmd) CloseStdin()

func (*TestCmd) ExitStatus

func (tt *TestCmd) ExitStatus() int

ExitStatus exposes the process' OS exit code It will only return a valid value after the process has finished.

func (*TestCmd) Expect

func (tt *TestCmd) Expect(tplsource string)

Expect runs its argument as a template, then expects the child process to output the result of the template within 5s.

If the template starts with a newline, the newline is removed before matching.

func (*TestCmd) ExpectExit

func (tt *TestCmd) ExpectExit()

ExpectExit expects the child process to exit within 5s without printing any additional text on stdout.

func (*TestCmd) ExpectRegexp

func (tt *TestCmd) ExpectRegexp(regex string) (*regexp.Regexp, []string)

ExpectRegexp expects the child process to output text matching the given regular expression within 5s.

Note that an arbitrary amount of output may be consumed by the regular expression. This usually means that expect cannot be used after ExpectRegexp.

func (*TestCmd) InputLine

func (tt *TestCmd) InputLine(s string) string

InputLine writes the given text to the childs stdin. This method can also be called from an expect template, e.g.:

geth.expect(`Passphrase: {{.InputLine "password"}}`)

func (*TestCmd) Interrupt

func (tt *TestCmd) Interrupt()

func (*TestCmd) Kill

func (tt *TestCmd) Kill()

func (*TestCmd) Run

func (tt *TestCmd) Run(name string, args ...string)

Run exec's the current binary using name as argv[0] which will trigger the reexec init function for that name (e.g. "geth-test" in cmd/geth/run_test.go)

func (*TestCmd) SetTemplateFunc

func (tt *TestCmd) SetTemplateFunc(name string, fn interface{})

func (*TestCmd) StderrText

func (tt *TestCmd) StderrText() string

StderrText returns any stderr output written so far. The returned text holds all log lines after ExpectExit has returned.

func (*TestCmd) WaitExit

func (tt *TestCmd) WaitExit()

Jump to

Keyboard shortcuts

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