testing

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	// Name of the testcase
	Name string
	// Values of gloal variables before run
	Inputs map[string]interface{}
	// Expected values of global vars after run
	Outputs map[string]interface{}
	// The same as Script.StopWhen. Both are merged together so this can be used to override/extend the script stop-conditions
	StopWhen map[string]interface{}
	// Maximum amount of lines to run for this case
	MaxLines int
}

Case defines inputs and expected outputs for a run

type CaseRunner added in v0.0.19

type CaseRunner struct {
	Coordinator     *vm.Coordinator
	VMs             []*vm.VM
	VarTranslations []map[string]string
	Test            *Test
	Case            *Case
	StopConditions  map[string]*vm.Variable
	// If true, the VMs are already running, but currently paused
	Paused bool
	// This channel will be closed once the test-case has been executed
	Done chan struct{}
}

CaseRunner represents a prepared test-case that is ready to run

func (CaseRunner) Run added in v0.0.19

func (cr CaseRunner) Run() []error

Run executes the case-runner

type Test

type Test struct {
	// The path where the test-file was located. Used to retrieve the script files.
	Path string
	// Scripts to use in this test
	Scripts []string
	// ScriptContents contains the contents of the scripts in .Scripts, Used mainly for testing
	ScriptContents []string
	// Cases for this test
	Cases []Case
	// Maximum number of lines to run from the script (0=infinite)
	MaxLines int
	// Stop when is a map from global variable-name to value
	// Execution is stopped when at least one of the listed variables is equal to the value
	StopWhen map[string]interface{}
	// When true, ignore runtime errors during testing
	IgnoreErrs bool
	// The chip-type to use for execution
	ChipType string
	// Run tests on after another and keep the state between cases
	Sequential bool
	// contains filtered or unexported fields
}

Test defines a test-run

func Parse

func Parse(file []byte, path string) (Test, error)

Parse parses a yaml file into a Test path is the path from where the test was loaded. This is needed as the scripts are located relative to the test-file

func (*Test) GetRunner added in v0.0.19

func (t *Test) GetRunner(casenr int) (runner *CaseRunner, err error)

GetRunner creates an executable TestRunner for the given testcase

func (Test) GetScriptCode added in v0.0.20

func (t Test) GetScriptCode(index int) (string, error)

GetScriptCode returns the code for indexed script.

func (Test) Run

func (t Test) Run(callback func(Case)) []error

Run runs all test-cases

Jump to

Keyboard shortcuts

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