cmdtest

package
v0.0.0-...-7037f4e Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: GPL-3.0 Imports: 14 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()
	// contains filtered or unexported fields
}

func NewTestCmd

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

func (*TestCmd) CloseStdin

func (tt *TestCmd) CloseStdin()

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