perturber

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package perturber contains the logic for the test perturber.

Index

Constants

This section is empty.

Variables

View Source
var ErrCInspectorNil = errors.New("compiler inspector nil")

ErrCInspectorNil occurs if the perturber constructor is passed a nil compiler inspector.

Functions

func OnPerturb

func OnPerturb(m Message, obs ...Observer)

OnPerturb sends a perturb message m to each observer in obs.

Types

type Kind

type Kind uint8

Kind is the enumeration of kinds of perturber message.

const (
	// KindStart means that the perturber is starting.
	// Quantities points to the perturber's quantity set.
	KindStart Kind = iota
	// KindSeedChanged means that the perturber has now changed the seed.
	// Seed points to the new seed.
	KindSeedChanged
	// KindSamplingCorpus means that the perturber is now sampling the corpus.
	// The selected corpus will be announced as a series of OnBuild messages.
	KindSamplingCorpus
	// KindRandomisingOpts means that the perturber is now randomising the compiler optimisations.
	// The selected compilers will be announced as a series of OnCompilerConfig messages.
	KindRandomisingOpts
)

type Message

type Message struct {
	// Kind is the kind of message being sent.
	Kind Kind

	// Quantities points to the quantity set on start messages.
	Quantities *quantity.PerturbSet

	// Seed points to the seed set on seed-changed messages.
	Seed int64
}

Message is the type of messages sent through OnPerturb.

type Observer

type Observer interface {
	compiler.Observer
	builder.Observer

	// OnPerturb is sent when the perturber is doing something new.
	OnPerturb(m Message)
}

Observer is the type of observers for the perturber.

type Option

type Option func(*Perturber) error

Option is the type of options to the Planner constructor.

func ObserveWith

func ObserveWith(obs ...Observer) Option

ObserveWith adds each observer in obs to the observer pool.

func Options

func Options(opts ...Option) Option

Options applies each option in opts in turn.

func OverrideQuantities

func OverrideQuantities(qs quantity.PerturbSet) Option

OverrideQuantities overrides this planner's quantities with qs.

func UseFullCompilerIDs

func UseFullCompilerIDs(use bool) Option

UseFullCompilerIDs sets whether the perturber should name compilers with their 'full ID'. By default, it preserves their original IDs.

func UseSeed

func UseSeed(seed int64) Option

UseSeed overrides the seed used by the planner. If seed is UseDateSeed, a date-specific seed is generated at runtime.

type Perturber

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

Perturber holds all configuration for the test perturber.

func New

func New(ci compiler.Inspector, opts ...Option) (*Perturber, error)

New constructs a new perturber with the given compiler inspector and options.

func (*Perturber) Close

func (*Perturber) Close() error

Close does nothing.

func (*Perturber) Run

func (p *Perturber) Run(_ context.Context, inplan *plan.Plan) (*plan.Plan, error)

Run runs the test perturber on inplan. It returns a modified plan on success, which is guaranteed to be different from pn.

func (*Perturber) Stage

func (*Perturber) Stage() stage.Stage

Stage gets the appropriate stage for the perturber.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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