Documentation ¶
Overview ¶
Package env defines a scenario environment.
Index ¶
- Variables
- type CleanupFn
- type Dir
- type Env
- func (env *Env) AddOnCleanup(fn CleanupFn)
- func (env *Env) AddTermOnCleanup(cmd *exec.Cmd) chan error
- func (env *Env) Cleanup()
- func (env *Env) CurrentDir() *Dir
- func (env *Env) Dir() string
- func (env *Env) Name() string
- func (env *Env) NewChild(childName string, scInfo *ScenarioInstanceInfo) (*Env, error)
- func (env *Env) NewSubDir(subDirName string) (*Dir, error)
- func (env *Env) ScenarioInfo() *ScenarioInstanceInfo
- func (env *Env) WriteScenarioInfo() error
- type ParameterFlagSet
- type ScenarioInstanceInfo
Constants ¶
This section is empty.
Variables ¶
var CmdAttrs = cmnSyscall.CmdAttrs
CmdAttrs is the SysProcAttr that will ensure graceful cleanup (on Linux).
var ErrEarlyTerm = errors.New("env: sub-process exited early")
ErrEarlyTerm is the error passed over the error channel when a sub-process terminates prior to the Cleanup.
var ( // Flags has the configuration flags. Flags = flag.NewFlagSet("", flag.ContinueOnError) )
Functions ¶
This section is empty.
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is a directory for test data and output.
func GetRootDir ¶
func GetRootDir() *Dir
GetRootDir returns the global root Dir instance.
Warning: This is not guaranteed to be valid till after `Dir.Init` is called. Use of this routine from outside `oasis-test-runner/cmd` is strongly discouraged.
func (*Dir) NewLogWriter ¶
func (d *Dir) NewLogWriter(name string) (io.WriteCloser, error)
NewLogWriter creates a log file under a Dir with the provided name.
func (*Dir) NewSubDir ¶
NewSubDir creates a new subdirectory under a Dir, and returns the sub-directory's Dir.
func (*Dir) SetNoCleanup ¶
SetNoCleanup enables/disables the removal of the Dir on Cleanup.
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a (nested) test environment.
func (*Env) AddOnCleanup ¶
AddOnCleanup adds a cleanup routine to be called during the environment's cleanup. Routines will be called in reverse order that they were registered.
func (*Env) AddTermOnCleanup ¶
AddTermOnCleanup adds a process that will be terminated during the environment's cleanup, and will return a channel that will be closed (after an error is sent if applicable when the process terminates.
Process will be terminated in the reverse order that they were registered.
Processes are torn down *BEFORE* the on-cleanup hooks are run.
func (*Env) Cleanup ¶
func (env *Env) Cleanup()
Cleanup cleans up all of the environment's children, followed by the environment.
Note: Unless the env is a root (top-level) environment, the directory will not be cleaned up.
func (*Env) CurrentDir ¶
CurrentDir returns the test environment's Dir.
func (*Env) NewChild ¶
func (env *Env) NewChild(childName string, scInfo *ScenarioInstanceInfo) (*Env, error)
NewChild returns a new child test environment.
func (*Env) ScenarioInfo ¶
func (env *Env) ScenarioInfo() *ScenarioInstanceInfo
ScenarioInfo returns the scenario instance information.
func (*Env) WriteScenarioInfo ¶
WriteScenarioInfo dumps scenario instance parameter set to scenario_info.json file for debugging afterwards.
type ParameterFlagSet ¶
ParameterFlagSet is a wrapper for flag.FlagSet to produce nicer JSON output.
func NewParameterFlagSet ¶
func NewParameterFlagSet(name string, eh flag.ErrorHandling) *ParameterFlagSet
NewParameterFlagSet returns new instance of ParameterFlagSet.
func (*ParameterFlagSet) Clone ¶
func (pfs *ParameterFlagSet) Clone() *ParameterFlagSet
Clone clones the parameter flagset.
This function is usually called when cloning scenarios where we also want to clone existing parameter values.
func (*ParameterFlagSet) MarshalJSON ¶
func (pfs *ParameterFlagSet) MarshalJSON() ([]byte, error)
MarshalJSON outputs ParameterFlagSet as an ordinary JSON map.
type ScenarioInstanceInfo ¶
type ScenarioInstanceInfo struct { // Scenario is the name of the scenario. Scenario string `json:"scenario"` // Instance is the name of the scenario instance (e.g. oasis-test-runner123456). Instance string `json:"instance"` // ParameterSet is the parameter set the scenario was run with. ParameterSet *ParameterFlagSet `json:"parameter_set"` // Run is the number of the run. Run int `json:"run"` }
ScenarioInstanceInfo contains information of the current scenario run.