test

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package test provides a task for the Go toolchain "test" command.

Index

Constants

View Source
const (
	// DefaultIntegrationTestTag is the default tag name for integration tests.
	DefaultIntegrationTestTag = "integration"

	// DefaultBlockProfileOutputFileName is the default file name for the Goroutine blocking profile file.
	DefaultBlockProfileOutputFileName = "block_profile.out"

	// DefaultCoverageOutputFileName is the default file name for the test coverage profile file.
	DefaultCoverageOutputFileName = "cover_profile.out"

	// DefaultCPUProfileOutputFileName is the default file name for the CPU profile file.
	DefaultCPUProfileOutputFileName = "cpu_profile.out"

	// DefaultMemoryProfileOutputFileName is the default file name for the memory profile file.
	DefaultMemoryProfileOutputFileName = "mem_profile.out"

	// DefaultMutexProfileOutputFileName is the default file name for the mutex profile file.
	DefaultMutexProfileOutputFileName = "mutex_profile.out"

	// DefaultOutputDirName is the default output directory name for test artifacts like profiles and reports.
	DefaultOutputDirName = "test"

	// DefaultTraceProfileOutputFileName is the default file name for the execution trace profile file.
	DefaultTraceProfileOutputFileName = "trace_profile.out"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is a task option.

func WithBlockProfile

func WithBlockProfile(withBlockProfile bool) Option

WithBlockProfile indicates whether the tests should be run with a Goroutine blocking profiling.

See `go help test` and the `go` command documentations for more details:

func WithBlockProfileOutputFileName

func WithBlockProfileOutputFileName(blockProfileOutputFileName string) Option

WithBlockProfileOutputFileName sets the file name for the Goroutine blocking profile file. Defaults to DefaultBlockProfileOutputFileName

See `go help test` and the `go` command documentations for more details:

func WithCPUProfile

func WithCPUProfile(withCPUProfile bool) Option

WithCPUProfile indicates whether the tests should be run with CPU profiling.

See `go help test` and the `go` command documentations for more details:

func WithCPUProfileOutputFileName

func WithCPUProfileOutputFileName(cpuProfileOutputFileName string) Option

WithCPUProfileOutputFileName sets the file name for the CPU profile file. Defaults to DefaultCPUProfileOutputFileName.

See `go help test` and the `go` command documentations for more details:

func WithCoverageProfile

func WithCoverageProfile(withCoverageProfile bool) Option

WithCoverageProfile indicates whether the tests should be run with coverage profiling.

See `go help test` and the `go` command documentations for more details:

func WithCoverageProfileOutputFileName

func WithCoverageProfileOutputFileName(coverageProfileOutputFileName string) Option

WithCoverageProfileOutputFileName sets the file name for the test coverage profile file. Defaults to DefaultCoverageOutputFileName.

See `go help test` and the `go` command documentations for more details:

func WithFlags

func WithFlags(flags ...string) Option

WithFlags sets additional flags that are passed to the Go "test" command along with the shared Go flags.

See `go help test` and the `go` command documentations for more details:

func WithGoOptions

func WithGoOptions(goOpts ...taskGo.Option) Option

WithGoOptions sets shared Go toolchain task options.

func WithMemoryProfile

func WithMemoryProfile(withMemoryProfile bool) Option

WithMemoryProfile indicates whether the tests should be run with memory profiling.

See `go help test` and the `go` command documentations for more details:

func WithMemoryProfileOutputFileName

func WithMemoryProfileOutputFileName(memoryProfileOutputFileName string) Option

WithMemoryProfileOutputFileName sets the file name for the memory profile file. Defaults to DefaultMemoryProfileOutputFileName.

See `go help test` and the `go` command documentations for more details:

func WithMutexProfile

func WithMutexProfile(withMutexProfile bool) Option

WithMutexProfile indicates whether the tests should be run with mutex profiling.

See `go help test` and the `go` command documentations for more details:

func WithMutexProfileOutputFileName

func WithMutexProfileOutputFileName(mutexProfileOutputFileName string) Option

WithMutexProfileOutputFileName sets the file name for the mutex profile file. Defaults to DefaultMutexProfileOutputFileName.

See `go help test` and the `go` command documentations for more details:

func WithOutputDir

func WithOutputDir(outputDir string) Option

WithOutputDir sets the output directory, relative to the project root, for reports like coverage or benchmark profiles. Defaults to DefaultOutputDirName.

See `go help test` and the `go` command documentations for more details:

func WithPkgs

func WithPkgs(pkgs ...string) Option

WithPkgs sets the list of packages to test.

See `go help test` and the `go` command documentations for more details:

func WithTraceProfile

func WithTraceProfile(withTraceProfile bool) Option

WithTraceProfile indicates whether the tests should be run with trace profiling.

See `go help test` and the `go` command documentations for more details:

func WithTraceProfileOutputFileName

func WithTraceProfileOutputFileName(traceProfileOutputFileName string) Option

WithTraceProfileOutputFileName sets the file name for the execution trace profile file. Defaults to DefaultTraceProfileOutputFileName.

See `go help test` and the `go` command documentations for more details:

func WithVerboseOutput

func WithVerboseOutput(withVerboseOutput bool) Option

WithVerboseOutput indicates whether the test output should be verbose.

See `go help test` and the `go` command documentations for more details:

func WithoutCache

func WithoutCache(withoutCache bool) Option

WithoutCache indicates whether the tests should be run without test caching that is enabled by Go by default.

See `go help test` and the `go` command documentations for more details:

type Options

type Options struct {
	*taskGo.Options

	// BlockProfileOutputFileName is the file name for the Goroutine blocking profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	BlockProfileOutputFileName string

	// CoverageProfileOutputFileName is the file name for the test coverage profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	CoverageProfileOutputFileName string

	// CPUProfileOutputFileName is the file name for the CPU profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	CPUProfileOutputFileName string

	// DisableCache indicates whether the tests should be run without test caching that is enabled by Go by default.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	DisableCache bool

	// EnableBlockProfile indicates whether the tests should be run with a Goroutine blocking profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableBlockProfile bool

	// EnableCoverageProfile indicates whether the tests should be run with coverage profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableCoverageProfile bool

	// EnableCPUProfile indicates whether the tests should be run with CPU profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableCPUProfile bool

	// EnableMemoryProfile indicates whether the tests should be run with memory profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableMemoryProfile bool

	// EnableMutexProfile indicates whether the tests should be run with mutex profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableMutexProfile bool

	// EnableTraceProfile indicates whether the tests should be run with trace profiling.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableTraceProfile bool

	// EnableVerboseOutput indicates whether the test output should be verbose.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	EnableVerboseOutput bool

	// Flags are additional flags that are passed to the Go `test` command along with the base Go flags.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	//   - https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
	Flags []string

	// MemoryProfileOutputFileName is the file name for the memory profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	MemoryProfileOutputFileName string

	// MutexProfileOutputFileName is the file name for the mutex profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	MutexProfileOutputFileName string

	// OutputDir is the output directory, relative to the project root, for reports like
	// coverage or benchmark profiles.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	OutputDir string

	// Pkgs is a list of packages to test.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	Pkgs []string

	// TraceProfileOutputFileName is the file name for the execution trace profile file.
	//
	// See `go help test` and the `go` command documentations for more details:
	//   - https://golang.org/cmd/go/#hdr-Testing_flags
	TraceProfileOutputFileName string
	// contains filtered or unexported fields
}

Options are parameter build options.

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions creates new task options.

type Task

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

Task is a task for the Go toolchain "test" command.

func New

func New(ac app.Config, opts ...Option) *Task

New creates a new task for the Go toolchain "test" command.

func (*Task) BuildParams

func (t *Task) BuildParams() []string

BuildParams builds the parameters. Note that configured flags are applied after the "GOFLAGS" environment variable and could overwrite already defined flags. In addition, the output directory for test artifacts like profiles and reports must exist or must be be created before, otherwise the "test" Go toolchain command will fail to run.

See `go help environment`, `go help env` and the `go` command documentations for more details:

func (*Task) Env

func (t *Task) Env() map[string]string

Env returns the task specific environment.

func (*Task) Kind

func (t *Task) Kind() task.Kind

Kind returns the task kind.

func (*Task) Name added in v0.6.0

func (t *Task) Name() string

Name returns the unique task name.

func (*Task) Options

func (t *Task) Options() task.Options

Options returns the task options.

Jump to

Keyboard shortcuts

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