Documentation ¶
Index ¶
- Constants
- Variables
- func CheckLabel(labels, notLabels map[string]bool, config RunConfig) bool
- func IsGroup(path string) bool
- func IsTest(path string) bool
- func ParseLabels(labels string) (map[string]bool, map[string]bool)
- func ValidatePattern(args []string) (string, error)
- type ByOrder
- type Group
- type GroupCommand
- type Info
- type OSInfo
- type Project
- type Result
- type RunConfig
- type Summary
- type Tags
- type Test
- type TestContainer
- type TestResult
Constants ¶
const ( // GroupFileName is the name of the group script (without the extension) GroupFileName = "group" // PreTestFileName is the name of a pre-test script (without the extension) PreTestFileName = "pre-test" // PostTestFileName is the name of a post-test script (without the extension) PostTestFileName = "post-test" // TestFileName is the name of a test script (without the extension) TestFileName = "test" )
const ( // Pass is a test pass Pass = iota // Fail is a test failure Fail // Skip is a test skip Skip // Cancel is a test cancellation Cancel )
Variables ¶
var TestResultColorFunc = map[TestResult]func(a ...interface{}) string{}
TestResultColorFunc provides a mapping of numerical result values to a fmt.Sprintf() style function
var TestResultNames = map[TestResult]string{ Pass: "Pass", Fail: "Fail", Skip: "Skip", Cancel: "Cancel", }
TestResultNames provides a mapping of numerical result values to human readable strings
Functions ¶
func CheckLabel ¶
CheckLabel determines if a group or test should run based on its labels and the RunConfig
func ParseLabels ¶
ParseLabels constucts a map[string]bool for both positive and negative labels from a comma separated list
func ValidatePattern ¶
ValidatePattern validates that an arg string is a valid test pattern
Types ¶
type ByOrder ¶
type ByOrder []TestContainer
ByOrder implements the sort.Sorter interface for TestContainer
type Group ¶
type Group struct { Parent *Group Tags *Tags Path string GroupFilePath string PreTestPath string PostTestPath string Labels map[string]bool NotLabels map[string]bool Children []TestContainer // contains filtered or unexported fields }
Group is a group of tests and other groups
func (*Group) Gather ¶
func (g *Group) Gather(config RunConfig) ([]TestContainer, int)
Gather gathers all runnable child groups and tests
func (*Group) Init ¶
Init is the group initialization function and should be called immediately after a group has been created
func (*Group) LabelString ¶
LabelString provides all labels in a comma separated list
type GroupCommand ¶
GroupCommand is a command that is runnable, either a test or pre/post script.
func (GroupCommand) Gather ¶
func (g GroupCommand) Gather(config RunConfig) ([]TestContainer, int)
Gather satisfies the TestContainer interface
func (GroupCommand) List ¶
func (g GroupCommand) List(config RunConfig) []Info
List satisfies the TestContainer interface
type Info ¶
type Info struct { Name string TestResult TestResult Summary string Issue string Labels map[string]bool NotLabels map[string]bool }
Info encapsulates the information necessary to list tests and test groups
func (*Info) LabelString ¶
LabelString returns all labels in a comma separated string
type Project ¶
type Project struct { *Group // contains filtered or unexported fields }
Project is a group of tests and other groups with a few higher level functions
func InitNewProject ¶
InitNewProject creates a new Group, and calls Init() on it
func NewProject ¶
NewProject creates a new top-level Group at the provided path
type Result ¶
type Result struct { Test *Test `json:"-"` Name string `json:"name,omitempty"` // Name may be different to Test.Name() for repeated tests. TestResult TestResult `json:"result"` BenchmarkResult string `json:"benchmark,omitempty"` StartTime time.Time `json:"start,omitempty"` EndTime time.Time `json:"end,omitempty"` Duration time.Duration `json:"duration,omitempty"` }
Result encapsulates a TestResult and additional data about a test run
type RunConfig ¶
type RunConfig struct { Extra bool CaseDir string LogDir string Logger logger.LogDispatcher SystemInfo sysinfo.SystemInfo Labels map[string]bool NotLabels map[string]bool TestPattern string Parallel bool IncludeInit bool // contains filtered or unexported fields }
RunConfig contains runtime configuration information
func NewRunConfig ¶
NewRunConfig returns a new RunConfig from test labels and a pattern
type Summary ¶
type Summary struct { ID string `json:"id,omitempty"` StartTime time.Time `json:"start,omitempty"` EndTime time.Time `json:"end,omitempty"` SystemInfo sysinfo.SystemInfo `json:"system,omitempty"` Labels []string `json:"labels,omitempty"` Results []Result `json:"results,omitempty"` }
Summary contains a summary of a whole run, mostly used for writing out a JSON file
type Tags ¶
type Tags struct { Name string `rt:"NAME"` Summary string `rt:"SUMMARY"` Author string `rt:"AUTHOR,allowmultiple"` Labels string `rt:"LABELS"` Repeat int `rt:"REPEAT"` Issue string `rt:"ISSUE,allowmultiple"` }
Tags are the permitted tags within a test file
type Test ¶
type Test struct { Parent *Group Tags *Tags Path string TestFilePath string Command exec.Cmd Repeat int Summary string Author string Labels map[string]bool NotLabels map[string]bool // contains filtered or unexported fields }
Test is a test
func (*Test) Gather ¶
func (t *Test) Gather(config RunConfig) ([]TestContainer, int)
Gather satisfies the TestContainer interface
func (*Test) LabelString ¶
LabelString returns all labels in a comma separated string
type TestContainer ¶
type TestContainer interface { Order() int List(config RunConfig) []Info Run(config RunConfig) ([]Result, error) Gather(config RunConfig) ([]TestContainer, int) }
TestContainer is a container that can hold one or more tests
type TestResult ¶
type TestResult int
TestResult is the result of a test run
func (TestResult) Sprintf ¶
func (r TestResult) Sprintf(format string, a ...interface{}) string
Sprintf prints the arguments using fmt.Sprintf but colours it depending on the TestResult