testcheck

package
v0.0.0-...-15a9a0c Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package testcheck provides common functions to check test definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attr

func Attr(t *gotesting.T, f TestFilter, requiredAttr []string)

Attr checks that tests matched by f declare requiredAttr as Attr. requiredAttr is a list of items which the test's Attr must have. Each item is one or '|'-connected multiple attr names, and Attr must contain at least one of them.

func Entities

func Entities() map[string]Entity

Entities gives all dependency data of all tests.

func IfAttr

func IfAttr(t *gotesting.T, f TestFilter, criteriaAttr, requiredAttr []string)

IfAttr checks that tests matched by f declare requiredAttr as Attr if all Attr in criteriaAttr are present. criteriaAttr is a list of items to apply to test's Attr. requiredAttr is a list of items which the test's Attr must have if criteriaAttr are matched. Each item is one or '|'-connected multiple attr names, and Attr must contain at least one of them. Example, criteriaAttr=["A", "B|C"], requiredAttr=["D", "E|F"] Any tests with Attr A and either B or C should define Attr D and either E or F.

func SetAllTestsforTest

func SetAllTestsforTest(tests []*testing.TestInstance) func()

SetAllTestsforTest sets all tests to use in this package. This is mainly used in unittest for testing purpose.

func SoftwareDeps

func SoftwareDeps(t *gotesting.T, f TestFilter, requiredDeps []string)

SoftwareDeps checks that tests matched by f declare requiredDeps as software dependencies. requiredDeps is a list of items which the test's SoftwareDeps needs to satisfy. Each item is one or '|'-connected multiple software feature names, and SoftwareDeps must contain at least one of them. TODO: b/225978622 -- support multi-dut in test check.

func Timeout

func Timeout(t *gotesting.T, f TestFilter, minTimeout time.Duration)

Timeout checks that tests matched by f have timeout no less than minTimeout.

Types

type Entity

type Entity struct {
	Type         EntityType
	Name         string
	Parent       string
	PrivateAttrs map[string]struct{}
	Attrs        map[string]struct{}
}

Entity represents a node in the dependency graph of tests and fixtures.

func (*Entity) HasAttr

func (e *Entity) HasAttr(name string) bool

HasAttr returns whether the node has given Attr.

func (*Entity) HasPrivateAttr

func (e *Entity) HasPrivateAttr(name string) bool

HasPrivateAttr returns whether the node has a given private attribute.

type EntityType

type EntityType int

EntityType represents a type of an entity, such as a test or a fixture.

const (
	// Test represents that an entity is a test.
	Test EntityType = iota
	// Fixture represents that an entity is a fixture.
	Fixture
)

func (EntityType) String

func (e EntityType) String() string

type TestFilter

type TestFilter func(t *testing.TestInstance) bool

TestFilter defines the condition whether or not the test should be checked.

func Glob

func Glob(t *gotesting.T, glob string) TestFilter

Glob returns a TestFilter which returns true for a test if the test name matches with the given glob pattern.

Jump to

Keyboard shortcuts

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