package
0.31.0
Repository: https://go.googlesource.com/tools
Documentation: pkg.go.dev

# Functions

Command is like exec.Command, but applies the same changes as testenv.CommandContext (with a default Context).
CommandContext is like exec.CommandContext, but: - skips t if the platform does not support os/exec, - if supported, sends SIGQUIT instead of SIGKILL in its Cancel function - if the test has a deadline, adds a Context timeout and (if supported) WaitDelay for an arbitrary grace period before the test's deadline expires, - if Cmd has the Cancel field, fails the test if the command is canceled due to the test's deadline, and - sets a Cleanup function that verifies that the test did not leak a subprocess.
Deadline returns the deadline of t, if known, using the Deadline method added in Go 1.15.
ExitIfSmallMachine emits a helpful diagnostic and calls os.Exit(0) if the current machine is a builder known to have scarce resources.
Go1Point returns the x in Go 1.x.
GOROOT reports the path to the directory containing the root of the Go project source tree.
HasExec reports whether the current system can start new processes using os.StartProcess or (more commonly) exec.Command.
HasTool reports an error if the required tool is not available in PATH.
NeedsDefaultImporter skips t if the test uses the default importer, returned by [go/importer.Default].
NeedsExec checks that the current system can start new processes using os.StartProcess or (more commonly) exec.Command.
NeedsGo1Point skips t if the Go version used to run the test is older than 1.x.
NeedsGoBuild skips t if the current system can't build programs with “go build” and then run them with os.StartProcess or exec.Command.
NeedsGoCommand1Point skips t if the ambient go command version in the PATH of the current process is older than 1.x.
NeedsGoExperiment skips t if the current process environment does not have a GOEXPERIMENT flag set.
NeedsGoPackages skips t if the go/packages driver (or 'go' tool) implied by the current process environment is not present in the path.
NeedsGoPackagesEnv skips t if the go/packages driver (or 'go' tool) implied by env is not present in the path.
NeedsGOROOTDir skips the test if GOROOT/dir does not exist, and GOROOT is a released version of Go (=has a VERSION file).
NeedsLocalhostNet skips t if networking does not work for ports opened with "localhost".
NeedsLocalXTools skips t if the golang.org/x/tools module is replaced and its replacement directory does not exist (or does not contain the module).
NeedsTool skips t if the named tool is not present in the path.
RedirectStderr causes os.Stderr (and the global logger) to be temporarily replaced so that writes to it are sent to t.Log.
SkipAfterGo1Point skips t if the Go version used to run the test is newer than 1.x.
SkipAfterGoCommand1Point skips t if the ambient go command version in the PATH of the current process is newer than 1.x.
WriteImportcfg writes an importcfg file used by the compiler or linker to dstPath containing entries for the packages in std and cmd in addition to the package to package file mappings in additionalPackageFiles.

# Variables

Sigquit is the signal to send to kill a hanging subprocess.