gotest

package
v0.0.0-...-eeee692 Latest Latest
Warning

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

Go to latest
Published: May 25, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GotestPluginName      = "gotest"
	ParseFilesCommandName = "parse_files"
	ResultsAPIEndpoint    = "gotest_results"
	TestLogsAPIEndpoint   = "gotest_logs"
	ResultsPostRetries    = 5
	ResultsRetrySleepSec  = 10 * time.Second
)
View Source
const (
	PASS = "PASS"
	FAIL = "FAIL"
	SKIP = "SKIP"

	// Match the start prefix and save the group of non-space characters following the word "RUN"
	StartRegexString = `=== RUN\s+(\S+)`

	// Match the end prefix, save PASS/FAIL/SKIP, save the decimal value for number of seconds
	EndRegexString = `--- (PASS|SKIP|FAIL): (\S+) \(([0-9.]+[ ]*s)`

	// Match the start prefix and save the group of non-space characters following the word "RUN"
	GocheckStartRegexString = `START: .*.go:[0-9]+: (\S+)`

	// Match the end prefix, save PASS/FAIL/SKIP, save the decimal value for number of seconds
	GocheckEndRegexString = `(PASS|SKIP|FAIL): .*.go:[0-9]+: (\S+)\s*([0-9.]+[ ]*s)?`
)

Variables

This section is empty.

Functions

func ParseTestOutputFiles

func ParseTestOutputFiles(outputFiles []string, stop chan bool,
	pluginLogger plugin.Logger, taskConfig *model.TaskConfig) ([]model.TestLog,
	[][]*TestResult, error)

ParseTestOutputFiles parses all of the files that are passed in, and returns the test logs and test results found within.

func ToModelTestResults

func ToModelTestResults(_ *task.Task, results []*TestResult) task.TestResults

ToModelTestResults converts the implementation of TestResults native to the gotest plugin to the implementation used by MCI tasks

Types

type GotestPlugin

type GotestPlugin struct{}

func (*GotestPlugin) Name

func (self *GotestPlugin) Name() string

func (*GotestPlugin) NewCommand

func (self *GotestPlugin) NewCommand(cmdName string) (plugin.Command, error)

type ParseFilesCommand

type ParseFilesCommand struct {
	// a list of filename blobs to include
	// e.g. "monitor.suite", "output/*"
	Files []string `mapstructure:"files" plugin:"expand"`
}

ParseFilesCommand is a struct implementing plugin.Command. It is used to parse a file or series of files containing the output of go tests, and send the results back to the server.

func (*ParseFilesCommand) AllOutputFiles

func (pfCmd *ParseFilesCommand) AllOutputFiles() ([]string, error)

AllOutputFiles creates a list of all test output files that will be parsed, by expanding all of the file patterns specified to the command.

func (*ParseFilesCommand) Execute

func (pfCmd *ParseFilesCommand) Execute(pluginLogger plugin.Logger,
	pluginCom plugin.PluginCommunicator, taskConfig *model.TaskConfig,
	stop chan bool) error

Execute parses the specified output files and sends the test results found in them back to the server.

func (*ParseFilesCommand) Name

func (pfCmd *ParseFilesCommand) Name() string

Name returns the string name for the parse files command.

func (*ParseFilesCommand) ParseParams

func (pfCmd *ParseFilesCommand) ParseParams(params map[string]interface{}) error

ParseParams reads the specified map of parameters into the ParseFilesCommand struct, and validates that at least one file pattern is specified.

func (*ParseFilesCommand) Plugin

func (pfCmd *ParseFilesCommand) Plugin() string

type Parser

type Parser interface {
	// Parse takes a reader for test output, and reads
	// until the reader is exhausted. Any parsing erros
	// are returned.
	Parse(io.Reader) error

	// Logs returns an array of strings, each entry a line in
	// the test output.
	Logs() []string

	// Results returns an array of test results. Parse() must be called
	// before this.
	Results() []*TestResult
}

Parser is an interface for parsing go test output, producing test logs and test results

type TestResult

type TestResult struct {
	// The name of the test
	Name string
	// The name of the test suite the test is a part of.
	// Currently, for this plugin, this is the name of the package
	// being tested, prefixed with a unique number to avoid
	// collisions when packages have the same name
	SuiteName string
	// The result status of the test
	Status string
	// How long the test took to run
	RunTime time.Duration
	// Number representing the starting log line number of the test
	// in the test's logged output
	StartLine int
	// Number representing the last line of the test in log output
	EndLine int

	// Can be set to mark the id of the server-side log that this
	// results corresponds to
	LogId string
}

This test result implementation maps more idiomatically to Go's test output than the TestResult type in the model package. Results are converted to the model type before being sent to the server.

type VanillaParser

type VanillaParser struct {
	Suite string
	// contains filtered or unexported fields
}

VanillaParser parses tests following go test output format. This should cover regular go tests as well as those written with the popular testing packages goconvey and gocheck.

func (*VanillaParser) Logs

func (vp *VanillaParser) Logs() []string

Logs returns an array of logs captured during test execution.

func (*VanillaParser) Parse

func (vp *VanillaParser) Parse(testOutput io.Reader) error

Parse reads in a test's output and stores the results and logs.

func (*VanillaParser) Results

func (vp *VanillaParser) Results() []*TestResult

Results returns an array of test results parsed during test execution.

Jump to

Keyboard shortcuts

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