cmd

package
v0.195.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestCommand

func TestCommand(setup TestSetupFunc) *cobra.Command

func WithFeatureFlags

func WithFeatureFlags(ctx context.Context, features string) (context.Context, error)

Types

type IntHeap

type IntHeap []int

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Pop

func (h *IntHeap) Pop() interface{}

func (*IntHeap) Push

func (h *IntHeap) Push(x interface{})

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type Test

type Test struct {
	// contains filtered or unexported fields
}

Test wraps the functionality of a single testcase statement, to handle its execution and its skip/pass/fail state.

func NewTest

func NewTest(name string, ast *ast.Package, tags []string, pkg string) Test

NewTest creates a new Test instance from an ast.Package.

func (*Test) Error

func (t *Test) Error() error

Get the error from the test, if one exists.

func (*Test) FullName

func (t *Test) FullName() string

func (*Test) Name

func (t *Test) Name() string

Get the name of the Test.

func (*Test) PackageName

func (t *Test) PackageName() string

func (*Test) Run

func (t *Test) Run(executor TestExecutor)

Run the test, saving the error to the err property of the struct.

func (*Test) SourceCode

func (t *Test) SourceCode() (string, error)

type TestExecutor

type TestExecutor interface {
	// Run will run the given package against the current test harness.
	// The result must be passed to the read function to be processed.
	Run(pkg *ast.Package, fn TestResultFunc) error
	io.Closer
}

type TestFlags

type TestFlags struct {
	// contains filtered or unexported fields
}

type TestReporter

type TestReporter struct {
	// contains filtered or unexported fields
}

TestReporter handles reporting of test results.

func (*TestReporter) ReportTestRun

func (t *TestReporter) ReportTestRun(test *Test)

ReportTestRun reports the result a single test run, intended to be run as each test is run.

func (*TestReporter) Summarize

func (t *TestReporter) Summarize(tests []*Test) bool

Summarize summarizes the test run.

type TestResultFunc

type TestResultFunc func(ctx context.Context, results flux.ResultIterator) error

TestResultFunc is a function that processes the result of running a test file. This function must be invoked from the implementation of TestExecutor.

type TestRunner

type TestRunner struct {
	// contains filtered or unexported fields
}

TestRunner gathers and runs all tests.

func NewTestRunner

func NewTestRunner(reporter TestReporter) TestRunner

NewTestRunner returns a new TestRunner.

func (*TestRunner) Finish

func (t *TestRunner) Finish() bool

Finish summarizes the test run, and returns an error in the event of a failure.

func (*TestRunner) Gather

func (t *TestRunner) Gather(roots []string) error

Gather gathers all tests from the filesystem and creates Test instances from that info.

func (*TestRunner) MarkSkipped

func (t *TestRunner) MarkSkipped(testNames, skips, tags []string, skipUntagged bool)

MarkSkipped checks the provided filters and marks each test case as skipped as needed.

Skip rules:

  • When testNames is not empty any test in the list will be run, all others skipped.
  • When a test name is in skips, the test is skipped.
  • When a test contains any tags all tags must be specified for the test to run.
  • When skipUntagged is true, any test that does not have any tags is skipped.

The list of tests takes precedence over all other parameters.

func (*TestRunner) Run

func (t *TestRunner) Run(executor TestExecutor, verbosity int)

func (*TestRunner) RunParallel

func (t *TestRunner) RunParallel(executor TestExecutor, verbosity int)

Run runs all tests, reporting their results.

type TestSetupFunc

type TestSetupFunc func(ctx context.Context) (TestExecutor, error)

Jump to

Keyboard shortcuts

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