package testenv

import "cuelang.org/go/internal/golangorgx/tools/testenv"

Package testenv contains helper functions for skipping tests based on which tools are present in the environment.

Index

Variables

var Sigquit = os.Kill

Sigquit is the signal to send to kill a hanging subprocess. On Unix we send SIGQUIT, but on non-Unix we only have os.Kill.

Functions

func Command

func Command(t testing.TB, name string, args ...string) *exec.Cmd

Command is like exec.Command, but applies the same changes as testenv.CommandContext (with a default Context).

func CommandContext

func CommandContext(t testing.TB, ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext is like exec.CommandContext, but:

func Deadline

func Deadline(t testing.TB) (time.Time, bool)

Deadline returns the deadline of t, if known, using the Deadline method added in Go 1.15.

func Go1Point

func Go1Point() int

Go1Point returns the x in Go 1.x.

func HasExec

func HasExec() bool

HasExec reports whether the current system can start new processes using os.StartProcess or (more commonly) exec.Command.

func NeedsExec

func NeedsExec(t testing.TB)

NeedsExec checks that the current system can start new processes using os.StartProcess or (more commonly) exec.Command. If not, NeedsExec calls t.Skip with an explanation.

func NeedsGo1Point

func NeedsGo1Point(t testing.TB, x int)

NeedsGo1Point skips t if the Go version used to run the test is older than 1.x.

func NeedsGoBuild

func NeedsGoBuild(t testing.TB)

NeedsGoBuild skips t if the current system can't build programs with “go build” and then run them with os.StartProcess or exec.Command. Android doesn't have the userspace go build needs to run, and js/wasm doesn't support running subprocesses.

func NeedsGoExperiment

func NeedsGoExperiment(t testing.TB, flag string)

NeedsGoExperiment skips t if the current process environment does not have a GOEXPERIMENT flag set.

func NeedsTool

func NeedsTool(t testing.TB, tool string)

NeedsTool skips t if the named tool is not present in the path. As a special case, "cgo" means "go" is present and can compile cgo programs.

func SkipAfterGo1Point

func SkipAfterGo1Point(t testing.TB, x int)

SkipAfterGo1Point skips t if the Go version used to run the test is newer than 1.x.

Source Files

exec.go testenv.go testenv_notunix.go

Version
v0.13.0 (latest)
Published
May 22, 2025
Platform
windows/amd64
Imports
16 packages
Last checked
1 minute ago

Tools for package owners.