gotest

package
v0.0.0-...-900fa13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GotestPluginName      = "gotest"
	RunTestCommandName    = "run"
	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+)`

	// Match the end prefix, save PASS/FAIL/SKIP, save the decimal value
	// for number of seconds
	EndRegexString = `--- (PASS|SKIP|FAIL): (\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 RunAndParseTests

func RunAndParseTests(conf TestConfig, parser Parser,
	pluginLogger plugin.Logger, stop <-chan bool) (bool, error)

func ToModelTestResults

func ToModelTestResults(task *model.Task, results []TestResult) model.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) Configure

func (self *GotestPlugin) Configure(map[string]interface{}) error

func (*GotestPlugin) GetAPIHandler

func (self *GotestPlugin) GetAPIHandler() http.Handler

func (*GotestPlugin) GetPanelConfig

func (self *GotestPlugin) GetPanelConfig() (*plugin.PanelConfig, error)

func (*GotestPlugin) GetUIHandler

func (self *GotestPlugin) GetUIHandler() http.Handler

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 RunTestCommand

type RunTestCommand struct {
	WorkDir string       `mapstructure:"working_dir" plugin:"expand"`
	Tests   []TestConfig `mapstructure:"tests" plugin:"expand"`
}

func (*RunTestCommand) Execute

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

func (*RunTestCommand) Name

func (self *RunTestCommand) Name() string

func (*RunTestCommand) ParseParams

func (self *RunTestCommand) ParseParams(params map[string]interface{}) error

func (*RunTestCommand) Plugin

func (self *RunTestCommand) Plugin() string

type TestConfig

type TestConfig struct {
	Dir                  string   `mapstructure:"dir" plugin:"expand"`
	Args                 string   `mapstructure:"args" plugin:"expand"`
	EnvironmentVariables []string `mapstructure:"environment_variables" plugin:"expand"`
}

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 regular go test output format. This should cover regular go tests as well as those written with the popular testing package "goconvey". The package"GoCheck" hides most test output, so it might be nice to add support for that at some point by building another parser.

func (*VanillaParser) Logs

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

Logs returns an array of logs captured during test execution.

func (*VanillaParser) Parse

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

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

func (*VanillaParser) Results

func (self *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