go-ethereum: github.com/ethereum/go-ethereum/internal/cmdtest Index | Files

package cmdtest

import "github.com/ethereum/go-ethereum/internal/cmdtest"


Package Files


type TestCmd Uses

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

    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 Uses

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

func (*TestCmd) CloseStdin Uses

func (tt *TestCmd) CloseStdin()

func (*TestCmd) ExitStatus Uses

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 Uses

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 Uses

func (tt *TestCmd) ExpectExit()

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

func (*TestCmd) ExpectRegexp Uses

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 Uses

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

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

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

func (*TestCmd) Interrupt Uses

func (tt *TestCmd) Interrupt()

func (*TestCmd) Kill Uses

func (tt *TestCmd) Kill()

func (*TestCmd) Run Uses

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 Uses

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

func (*TestCmd) StderrText Uses

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 Uses

func (tt *TestCmd) WaitExit()

Package cmdtest imports 16 packages (graph). Updated 2020-11-20. Refresh now. Tools for package owners.