go2hx

manual

github

Module: stdgo.internal.testenv

(view library index)

Overview

Package testenv provides information about what functionality is available in different testing environments run by the Go team.

It is an internal package because these details are specific to the Go team's test setup (on build.golang.org) and not fundamental to tests in general.

Index

Variables

import stdgo.internal.testenv.Testenv
var _execPaths:stdgo.sync.Map_

path -\> error

var _flaky:stdgo.Pointer<Bool>
var _goBuildErr:stdgo.Error
var _goBuildOnce:stdgo.sync.Once
var _goToolErr:stdgo.Error
var _goToolOnce:stdgo.sync.Once
var _goToolPath:stdgo.GoString
var _gorootErr:stdgo.Error
var _gorootOnce:stdgo.sync.Once
var _gorootPath:stdgo.GoString
var _hasCgo:Bool
var _hasCgoOnce:stdgo.sync.Once
var _origEnv:stdgo.Slice<stdgo.GoString>

Save the original environment during init for use in checks. A test binary may modify its environment before calling HasExec to change its behavior (such as mimicking a command-line tool), and that modified environment might cause environment checks to behave erratically.

var _tryExecErr:stdgo.Error
var _tryExecOnce:stdgo.sync.Once
var sigquit:stdgo.os.Signal

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

import stdgo.internal.testenv.Testenv

function _findGOROOT

function _findGOROOT():{
	_1:stdgo.Error;
	_0:stdgo.GoString;
}

(view code)

function _hasSymlink

function _hasSymlink():{
	_1:stdgo.GoString;
	_0:Bool;
}

(view code)

function _syscallIsNotSupported

function _syscallIsNotSupported(_err:stdgo.Error):Bool

(view code)

function _tryExec

function _tryExec():stdgo.Error

(view code)

function builder

function builder():stdgo.GoString

Builder reports the name of the builder running this test (for example, "linux-amd64" or "windows-386-gce"). If the test is not running on the build infrastructure, Builder returns the empty string.

(view code)

function canInternalLink

function canInternalLink(_withCgo:Bool):Bool

CanInternalLink reports whether the current system can link programs with internal linking.

(view code)

function cleanCmdEnv

function cleanCmdEnv(_cmd:stdgo.Ref<stdgo.os.exec.Cmd>):stdgo.Ref<stdgo.os.exec.Cmd>

CleanCmdEnv will fill cmd.Env with the environment, excluding certain variables that could modify the behavior of the Go tools such as GODEBUG and GOTRACEBACK.

(view code)

function command

function command(_t:stdgo.testing.TB, _name:stdgo.GoString, _args:haxe.Rest<stdgo.GoString>):stdgo.Ref<stdgo.os.exec.Cmd>

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

(view code)

function commandContext

function commandContext(_t:stdgo.testing.TB, _ctx:stdgo.context.Context, _name:stdgo.GoString, _args:haxe.Rest<stdgo.GoString>):stdgo.Ref<stdgo.os.exec.Cmd>
 CommandContext is like exec.CommandContext, but:
   - skips t if the platform does not support os/exec,
   - sends SIGQUIT (if supported by the platform) instead of SIGKILL
     in its Cancel function
   - if the test has a deadline, adds a Context timeout and WaitDelay
     for an arbitrary grace period before the test's deadline expires,
   - fails the test if the command does not complete before the test's deadline, and
   - sets a Cleanup function that verifies that the test did not leak a subprocess.

(view code)

function cpuisSlow

function cpuisSlow():Bool

CPUIsSlow reports whether the CPU running the test is suspected to be slow.

(view code)

function goTool

function goTool():{
	_1:stdgo.Error;
	_0:stdgo.GoString;
}

GoTool reports the path to the Go tool.

(view code)

function goToolPath

function goToolPath(_t:stdgo.testing.TB):stdgo.GoString

GoToolPath reports the path to the Go tool. It is a convenience wrapper around GoTool. If the tool is unavailable GoToolPath calls t.Skip. If the tool should be available and isn't, GoToolPath calls t.Fatal.

(view code)

function goroot

function goroot(_t:stdgo.testing.TB):stdgo.GoString

GOROOT reports the path to the directory containing the root of the Go project source tree. This is normally equivalent to runtime.GOROOT, but works even if the test binary was built with -trimpath and cannot exec 'go env GOROOT'.

If GOROOT cannot be found, GOROOT skips t if t is non-nil, or panics otherwise.

(view code)

function hasCGO

function hasCGO():Bool

HasCGO reports whether the current system can use cgo.

(view code)

function hasExternalNetwork

function hasExternalNetwork():Bool

HasExternalNetwork reports whether the current system can use external (non-localhost) networks.

(view code)

function hasGoBuild

function hasGoBuild():Bool

HasGoBuild reports whether the current system can build programs with “go build” and then run them with os.StartProcess or exec.Command.

(view code)

function hasGoRun

function hasGoRun():Bool

HasGoRun reports whether the current system can run programs with “go run.”

(view code)

function hasLink

function hasLink():Bool

HasLink reports whether the current system can use os.Link.

(view code)

function hasParallelism

function hasParallelism():Bool

HasParallelism reports whether the current system can execute multiple threads in parallel. There is a copy of this function in cmd/dist/test.go.

(view code)

function hasSrc

function hasSrc():Bool

HasSrc reports whether the entire source tree is available under GOROOT.

(view code)

function hasSymlink

function hasSymlink():Bool

HasSymlink reports whether the current system can use os.Symlink.

(view code)

function mustHaveBuildMode

function mustHaveBuildMode(_t:stdgo.testing.TB, _buildmode:stdgo.GoString):Void

MustHaveBuildMode reports whether the current system can build programs in the given build mode. If not, MustHaveBuildMode calls t.Skip with an explanation.

(view code)

function mustHaveCGO

function mustHaveCGO(_t:stdgo.testing.TB):Void

MustHaveCGO calls t.Skip if cgo is not available.

(view code)

function mustHaveExec

function mustHaveExec(_t:stdgo.testing.TB):Void

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

On some platforms MustHaveExec checks for exec support by re-executing the current executable, which must be a binary built by 'go test'. We intentionally do not provide a HasExec function because of the risk of inappropriate recursion in TestMain functions.

To check for exec support outside of a test, just try to exec the command. If exec is not supported, testenv.SyscallIsNotSupported will return true for the resulting error.

(view code)

function mustHaveExecPath

function mustHaveExecPath(_t:stdgo.testing.TB, _path:stdgo.GoString):Void

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

(view code)

function mustHaveExternalNetwork

function mustHaveExternalNetwork(_t:stdgo.testing.TB):Void

MustHaveExternalNetwork checks that the current system can use external (non-localhost) networks. If not, MustHaveExternalNetwork calls t.Skip with an explanation.

(view code)

function mustHaveGoBuild

function mustHaveGoBuild(_t:stdgo.testing.TB):Void

MustHaveGoBuild checks that the current system can build programs with “go build” and then run them with os.StartProcess or exec.Command. If not, MustHaveGoBuild calls t.Skip with an explanation.

(view code)

function mustHaveGoRun

function mustHaveGoRun(_t:stdgo.testing.TB):Void

MustHaveGoRun checks that the current system can run programs with “go run.” If not, MustHaveGoRun calls t.Skip with an explanation.

(view code)

function mustHaveLink

function mustHaveLink(_t:stdgo.testing.TB):Void

MustHaveLink reports whether the current system can use os.Link. If not, MustHaveLink calls t.Skip with an explanation.

(view code)

function mustHaveParallelism

function mustHaveParallelism(_t:stdgo.testing.TB):Void

MustHaveParallelism checks that the current system can execute multiple threads in parallel. If not, MustHaveParallelism calls t.Skip with an explanation.

(view code)

function mustHaveSymlink

function mustHaveSymlink(_t:stdgo.testing.TB):Void

MustHaveSymlink reports whether the current system can use os.Symlink. If not, MustHaveSymlink calls t.Skip with an explanation.

(view code)

function mustInternalLink

function mustInternalLink(_t:stdgo.testing.TB, _withCgo:Bool):Void

MustInternalLink checks that the current system can link programs with internal linking. If not, MustInternalLink calls t.Skip with an explanation.

(view code)

function optimizationOff

function optimizationOff():Bool

OptimizationOff reports whether optimization is disabled.

(view code)

function skipFlaky

function skipFlaky(_t:stdgo.testing.TB, _issue:stdgo.GoInt):Void

(view code)

function skipFlakyNet

function skipFlakyNet(_t:stdgo.testing.TB):Void

(view code)

function skipIfOptimizationOff

function skipIfOptimizationOff(_t:stdgo.testing.TB):Void

SkipIfOptimizationOff skips t if optimization is disabled.

(view code)

function skipIfShortAndSlow

function skipIfShortAndSlow(_t:stdgo.testing.TB):Void

SkipIfShortAndSlow skips t if -short is set and the CPU running the test is suspected to be slow.

(This is useful for CPU-intensive tests that otherwise complete quickly.)

(view code)

function syscallIsNotSupported

function syscallIsNotSupported(_err:stdgo.Error):Bool

SyscallIsNotSupported reports whether err may indicate that a system call is not supported by the current platform or execution environment.

(view code)

function writeImportcfg

function writeImportcfg(_t:stdgo.testing.TB, _dstPath:stdgo.GoString, _packageFiles:stdgo.GoMap<stdgo.GoString, stdgo.GoString>, _pkgs:haxe.Rest<stdgo.GoString>):Void

WriteImportcfg writes an importcfg file used by the compiler or linker to dstPath containing entries for the file mappings in packageFiles, as well as for the packages transitively imported by the package(s) in pkgs.

pkgs may include any package pattern that is valid to pass to 'go list', so it may also be a list of Go source files all in the same directory.

(view code)

Typedefs

import stdgo.internal.testenv.*

typedef T__interface_0

typedef T__interface_0 = {
	public function tempDir():stdgo.GoString;
	public function skipped():Bool;
	public function skipf(_format:stdgo.GoString, _args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function skipNow():Void;
	public function skip(_args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function setenv(_key:stdgo.GoString, _value:stdgo.GoString):Void;
	public function name():stdgo.GoString;
	public function logf(_format:stdgo.GoString, _args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function log(_args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function helper():Void;
	public function fatalf(_format:stdgo.GoString, _args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function fatal(_args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function failed():Bool;
	public function failNow():Void;
	public function fail():Void;
	public function errorf(_format:stdgo.GoString, _args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function error(_args:haxe.Rest<stdgo.AnyInterface>):Void;
	public function deadline():{
		_1:Bool;
		_0:stdgo.time.Time;
	};
	public function cleanup(_0:():Void):Void;
};