run

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasketFlags

func BasketFlags() *pflag.FlagSet

BasketFlags returns a flagset with all flags for filtering objects.

BasketFlags are regular expressions to filter objects. If you pass multiple regular expressions, all of them must match (AND). Example:

$ cat example.ttcn3
testcase foo() ...
testcase bar() ...
testcase foobar() ...
...

$ ntt list --regex=foo --regex=bar
example.foobar

$ ntt list --regex='foo|bar'
example.foo
example.bar
example.foobar

Similarly, you can also specify regular expressions for documentation tags. Example:

$ cat example.ttcn3
// @one
// @two some-value
testcase foo() ...

// @two: some-other-value
testcase bar() ...
...

$ ntt list --tags-regex=@one --tags-regex=@two
example.foo

$ ntt list --tags-regex='@two: some'
example.foo
example.bar

func GenerateControls

func GenerateControls(files ...string) <-chan string

GenerateControls emits all control function ids from given TTCN-3 files to a channel.

func GenerateControlsWithContext

func GenerateControlsWithContext(ctx context.Context, b Basket, files ...string) <-chan string

GenerateControls emits all control function ids from given TTCN-3 files to a channel.

func GenerateIDs

func GenerateIDs(ids ...string) <-chan string

GenerateIDs emits given IDs to a channel.

func GenerateIDsWithContext

func GenerateIDsWithContext(ctx context.Context, ids ...string) <-chan string

GenerateIDs emits given IDs to a channel.

func GenerateTests

func GenerateTests(files ...string) <-chan string

GenerateTests emits all test ids from given TTCN-3 files to a channel.

func GenerateTestsWithContext

func GenerateTestsWithContext(ctx context.Context, b Basket, files ...string) <-chan string

GenerateTestsWithContext emits all test ids from given TTCN-3 files to a channel.

func SplitQualifiedName

func SplitQualifiedName(name string) (string, string)

SplitQualifiedName splits a qualified name into module and test name.

Types

type Basket

type Basket struct {
	// Name is the name of the basket. The basket is used to filter objects
	// by tag, if no explicit filters are given.
	Name string

	// Regular expressions the object name must match.
	NameRegex []string

	// Regular expressions the object name must not match.
	NameExclude []string

	// Regular expressions the object tags must match.
	TagsRegex []string

	// Regular expressions the object tags must not match.
	TagsExclude []string

	// Baskets are sub-baskets to be ORed.
	Baskets []Basket
}

A Basket is a filter for objects. It can be used to filter objects by name and tags.

Baskets are also filters defined by environment variables of the form:

NTT_LIST_BASKETS_<name> = <filters>

For example, to define a basket "stable" which excludes all objects with @wip or @flaky tags:

export NTT_LIST_BASKETS_stable="-X @wip|@flaky"

Baskets become active when they are listed in colon separated environment variable NTT_LIST_BASKETS. If you specify multiple baskets, at least of them must match (OR).

Rule of thumb: all baskets are ORed, all explicit filter options are ANDed. Example:

$ export NTT_LIST_BASKETS_stable="--tags-exclude @wip|@flaky"
$ export NTT_LIST_BASKETS_ipv6="--tags-regex @ipv6"
$ NTT_LIST_BASKETS=stable:ipv6 ntt list -R @flaky

Above example will output all tests with a @flaky tag and either @wip or @ipv6 tag.

If a basket is not defined by an environment variable, it's equivalent to a "--tags-regex" filter. For example, to lists all tests, which have either a @flaky or a @wip tag:

# Note, flaky and wip baskets are not specified explicitly.
$ NTT_LIST_BASKETS=flaky:wip ntt list

# This does the same:
$ ntt list --tags-regex="@wip|@flaky"

func NewBasket

func NewBasket(name string, args ...string) (Basket, error)

NewBasket creates a new basket and parses the given arguments.

func NewBasketWithFlags

func NewBasketWithFlags(name string, fs *pflag.FlagSet) (Basket, error)

func (*Basket) LoadFromEnvOrConfig

func (b *Basket) LoadFromEnvOrConfig(c *project.Config, key string) error

Load baskets from given environment variable from environment or from configuration.

func (*Basket) Match

func (b *Basket) Match(name string, tags [][]string) bool

Match returns true if the given name and tags match the basket or sub-basket filters.

type Job

type Job struct {
	// Full qualified name of the test or control function to be executed.
	Name string

	// Working directory for the job.
	Dir string

	// Test suite the job belongs to.
	Suite *Suite
	// contains filtered or unexported fields
}

Job represents a single job to be executed.

func (*Job) ID

func (j *Job) ID() string

A unique job identifier.

type Ledger

type Ledger struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Ledger is a worker pool for executing jobs.

func NewLedger

func NewLedger(n int) *Ledger

func (*Ledger) Done

func (l *Ledger) Done(job *Job)

func (*Ledger) Jobs

func (l *Ledger) Jobs() []*Job

func (*Ledger) NewJob

func (l *Ledger) NewJob(name string, suite *Suite) *Job

func (*Ledger) Run

func (l *Ledger) Run(ctx context.Context, jobs <-chan *Job) <-chan Result

type Result

type Result struct {
	*Job
	k3r.Test
	tests.Event
}

func (*Result) ID

func (r *Result) ID() string

type Runner

type Runner interface {
	// Run the jobs in the given channel.
	Run(ctx context.Context, jobs <-chan *Job) <-chan Result
}

Runner is a test runner.

type Suite

type Suite struct {
	*project.Config
	RuntimePaths []string
}

Suite represents a test suite.

func NewSuite

func NewSuite(p *project.Config) (*Suite, error)

NewSuite creates a new suite from the given files. It expects either a single directory as argument or a list of regular .ttcn3 files.

Calling NewSuite with an empty argument list will create a suite from current working directory or, if set, from NTT_SOURCE_DIR.

NewSuite will read manifest (package.yml) if any.

Jump to

Keyboard shortcuts

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