testutils

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureLog

func CaptureLog(t *testing.T, l *logrus.Logger)

CaptureLog redirects logrus output to testing.Log

func ContribPath

func ContribPath(fname string) string

ContribPath retrieves contrib path (useful to find scripts and other files)

func DontKeepExportFile

func DontKeepExportFile(t *testing.T) error

DontKeepExportFile: unmarks export file to be kept. This is meant for tests that are expected to fail.

func GetExportFilename

func GetExportFilename(t *testing.T) (string, error)

GetExportFilename return export filename for test

func GetSpecFromTemplate

func GetSpecFromTemplate(
	tmplname string,
	data interface{},
) (string, error)

GetSpecFromTemplate creates a file bsed on the given template

func KeepExportFile

func KeepExportFile(t *testing.T) error

KeepExportFile marks export file to be kept

Types

type CmdBufferedPipes

type CmdBufferedPipes struct {
	P                  *CmdPipes
	StdoutRd, StderrRd *bufio.Reader
}

CmdBufferedPipes wraps stdout and stderr in a bufio.Reader

func NewCmdBufferedPipes

func NewCmdBufferedPipes(cmd *exec.Cmd) (*CmdBufferedPipes, error)

func (*CmdBufferedPipes) Close

func (cbp *CmdBufferedPipes) Close()

func (*CmdBufferedPipes) ParseAndLogCmdOutput

func (cbp *CmdBufferedPipes) ParseAndLogCmdOutput(
	t *testing.T,
	parseOut LineParser,
	parseErr LineParser,
) *sync.WaitGroup

ParseAndLogCmdOutput will log command output using t.Log, and also call the lineparser functions for each line. This will happen in two goroutines. It returns a waitgroup for them finishing.

type CmdPipes

type CmdPipes struct {
	Stdout, Stderr io.ReadCloser
	Stdin          io.WriteCloser
}

CmdPipes maintains pipes for stdout, stderr, and stdin

func NewCmdPipes

func NewCmdPipes(cmd *exec.Cmd) (*CmdPipes, error)

NewCmdPipes returns a new CmdPipes

func (*CmdPipes) Close

func (cp *CmdPipes) Close()

Close closes all the pipes

type ExportFile

type ExportFile struct {
	*os.File
	// contains filtered or unexported fields
}

func CreateExportFile

func CreateExportFile(t *testing.T) (*ExportFile, error)

CreateExportFile creates an export file for a test. a callback will be registered at t.Cleanup() for closing the file, and removing the file

func (*ExportFile) Close

func (f *ExportFile) Close() error

type LineParser

type LineParser = func(line string) error

type LogCapturer

type LogCapturer struct {
	*testing.T
	Log *logrus.Logger
}

func (LogCapturer) Write

func (tl LogCapturer) Write(p []byte) (n int, err error)

Directories

Path Synopsis
Package perfring provides utilities to do tests using the perf ringbuffer directly
Package perfring provides utilities to do tests using the perf ringbuffer directly

Jump to

Keyboard shortcuts

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