Documentation
¶
Index ¶
- type Option
- type Options
- type Pipeline
- type PipelineResult
- type PipelineStage
- type Process
- func (p *Process) CaptureStderr() *bytes.Buffer
- func (p *Process) CaptureStdout() *bytes.Buffer
- func (p *Process) Close() error
- func (p *Process) Run(ctx context.Context, rt *toolkit.Runtime) *ProcessResult
- func (p *Process) RunWithIO(ctx context.Context, rt *toolkit.Runtime, r io.Reader) *ProcessResult
- func (p *Process) SetArgs(args []string)
- func (p *Process) SetStderr(w io.Writer)
- func (p *Process) SetStdin(r io.Reader)
- func (p *Process) SetStdout(w io.Writer)
- func (p *Process) StderrPipe() io.Reader
- func (p *Process) StdoutPipe() io.Reader
- func (p *Process) Write(b []byte) (int, error)
- type ProcessResult
- type Runner
- type Sandbox
- func (sandbox *Sandbox) AbsPath(rel string) (string, error)
- func (sandbox *Sandbox) Advance(d time.Duration)
- func (sandbox *Sandbox) AtomicWriteFile(rel string, data []byte, perm os.FileMode) error
- func (sandbox *Sandbox) Context() context.Context
- func (sandbox *Sandbox) DumpFileContent(rel string)
- func (sandbox *Sandbox) DumpJailTree(maxDepth int)
- func (sandbox *Sandbox) GetHome() (string, error)
- func (sandbox *Sandbox) GetJail() string
- func (sandbox *Sandbox) Getwd() (string, error)
- func (sandbox *Sandbox) Mkdir(rel string, all bool) error
- func (sandbox *Sandbox) MustReadFile(rel string) []byte
- func (sandbox *Sandbox) MustWriteFile(path string, data []byte, perm os.FileMode)
- func (sandbox *Sandbox) Now() time.Time
- func (sandbox *Sandbox) ReadFile(rel string) ([]byte, error)
- func (sandbox *Sandbox) ResolvePath(rel string) (string, error)
- func (sandbox *Sandbox) Runtime() *toolkit.Runtime
- func (sandbox *Sandbox) Setwd(dir string) error
- func (sandbox *Sandbox) WriteFile(rel string, data []byte, perm os.FileMode) error
- type StageOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v1.0.0
type Option func(f *Sandbox)
Option is a function used to modify a Sandbox during construction.
func WithEnv ¶
WithEnv returns an Option that sets a single environment variable in the sandbox's Env.
func WithEnvMap ¶
WithEnvMap returns an Option that seeds multiple environment variables.
func WithFixture ¶
WithFixture copies an embedded fixture directory into the sandbox jail.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline manages execution of multiple stages with piped I/O.
func NewPipeline ¶
func NewPipeline(stages ...*PipelineStage) *Pipeline
NewPipeline constructs a Pipeline with the given stages.
func (*Pipeline) CaptureStderr ¶
CaptureStderr configures stderr capture and returns the buffer.
func (*Pipeline) CaptureStdout ¶
CaptureStdout configures stdout capture and returns the buffer.
func (*Pipeline) RunWithTimeout ¶
func (p *Pipeline) RunWithTimeout(ctx context.Context, rt *toolkit.Runtime, timeout time.Duration) *PipelineResult
RunWithTimeout executes the pipeline with a deadline.
type PipelineResult ¶
PipelineResult holds the outcome of pipeline execution.
type PipelineStage ¶
type PipelineStage struct {
// contains filtered or unexported fields
}
PipelineStage represents a single stage in a pipeline.
func Stage ¶
func Stage(name string, runner Runner) *PipelineStage
Stage constructs a PipelineStage with the given name and runner.
func StageWithName ¶
func StageWithName(name string, p *Process) *PipelineStage
StageWithName constructs a PipelineStage wrapping the provided Process.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process manages execution of a Runner with configurable streams.
func NewProcess ¶
NewProcess constructs a Process bound to a Runner function.
func NewProducer ¶
NewProducer constructs a Process that emits the provided lines to stdout.
func (*Process) CaptureStderr ¶
CaptureStderr configures stderr capture and returns the buffer.
func (*Process) CaptureStdout ¶
CaptureStdout configures stdout capture and returns the buffer.
func (*Process) StderrPipe ¶
StderrPipe returns a reader connected to the process stderr.
func (*Process) StdoutPipe ¶
StdoutPipe returns a reader connected to the process stdout.
type ProcessResult ¶
ProcessResult holds the outcome of process execution.
type Sandbox ¶
type Sandbox struct {
// contains filtered or unexported fields
}
Sandbox bundles common test setup used by package tests.
func NewSandbox ¶
NewSandbox constructs a Sandbox and applies given options.
func (*Sandbox) AtomicWriteFile ¶
func (*Sandbox) DumpFileContent ¶ added in v1.0.0
DumpFileContent reads and logs the content of a file in the sandbox.
func (*Sandbox) DumpJailTree ¶
DumpJailTree logs a tree of files and directories rooted at the sandbox jail.
func (*Sandbox) MustReadFile ¶
MustReadFile reads a file under the jail and fails the test on error.
func (*Sandbox) MustWriteFile ¶
MustWriteFile writes data under the jail and fails the test on error.
func (*Sandbox) ResolvePath ¶
ResolvePath returns an absolute runtime path with optional symlink resolution.