runner

package
v1.0.11344-acdf7a1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package runner allows you to run a binary in an acceptance test (scan output for ports, wait for start).

It is part of our belief that testing binaries that will be shipping into production with as little modification as is possible is one of the most effective ways of producing high value tests.

Binaries compiled using the testing/compiler can be used to produce binaries with coverage instrumentation. In that case setting a CoverageReportPath on a runner for one of those binaries will help produce a coverage report. Using runner.Stop will send the running process a INT signal, so the service should respond to that elegantly so that the report can be flushed to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

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

func (*Result) APIAddr

func (r *Result) APIAddr() string

func (*Result) AdminAddr

func (r *Result) AdminAddr() string

func (*Result) Logs

func (r *Result) Logs() string

func (*Result) Ready

func (r *Result) Ready(serverName string, duration time.Duration) error

Ready will return nil if ports have been detected and the server is reporting readiness. If serverName is not empty then the server port will be detected using the standard server output as expected when running an ex httpserver. If it is empty then only the admin server is detected.

func (*Result) Stop

func (r *Result) Stop() error

Stop the process, returning the exit error.

func (*Result) Wait

func (r *Result) Wait() chan error

Wait for the process to exit in a goroutine. The exit error is returned on the channel when the process exits.

type Runner

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

func New

func New(baseEnv ...string) *Runner

func NewWithDynamicEnv

func NewWithDynamicEnv(baseEnv []string, dynamicEnv func() []string) *Runner

func (*Runner) CoverageReportDir

func (r *Runner) CoverageReportDir(path string)

CoverageReportDir tells the runner where to attempt to output a coverage report. A report will be generated in the given directory using the name of the binary, and the extension .out

func (*Runner) Run

func (r *Runner) Run(serverName, binary string, extraEnv ...string) (*Result, error)

Run starts the output service and waits a few seconds to confirm it has started successfully. The caller is responsible for calling Runner.Stop. If serverName is not empty then the server port will be detected using the standard server output as expected when running an ex httpserver. If it is left blank then only the admin server is detected. For custom timeouts whilst waiting for readiness use Start and result.Ready

func (*Runner) Start

func (r *Runner) Start(binary string, extraEnv ...string) (*Result, error)

Start the `output` service, returning a buffer which contains the logs (stderr) of the process. The caller is responsible for calling Result.Stop and Runner.Stop.

func (*Runner) Stop

func (r *Runner) Stop() error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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