testlog

Imports

Imports #

"sync"
_ "unsafe"
"sync/atomic"

Constants & Variables

logger var #

logger is the current logger Interface. We use an atomic.Pointer in case test startup is racing with goroutines started during init. That must not cause a race detector failure, although it will still result in limited visibility into exactly what those goroutines do.

var logger *ast.IndexExpr

panicOnExit0 var #

panicOnExit0 is the flag used for PanicOnExit0. This uses a lock because the value can be cleared via a timer call that may race with calls to os.Exit

var panicOnExit0 struct{...}

Interfaces

Interface interface #

Interface is the interface required of test loggers. The os package will invoke the interface's methods to indicate that it is inspecting the given environment variables or files. Multiple goroutines may call these methods simultaneously.

type Interface interface {
Getenv(key string)
Stat(file string)
Open(file string)
Chdir(dir string)
}

Functions

Getenv function #

Getenv calls Logger().Getenv, if a logger has been set.

func Getenv(name string)

Logger function #

Logger returns the current test logger implementation. It returns nil if there is no logger.

func Logger() Interface

Open function #

Open calls Logger().Open, if a logger has been set.

func Open(name string)

PanicOnExit0 function #

PanicOnExit0 reports whether to panic on a call to os.Exit(0). This is in the testlog package because, like other definitions in package testlog, it is a hook between the testing package and the os package. This is used to ensure that an early call to os.Exit(0) does not cause a test to pass.

func PanicOnExit0() bool

SetLogger function #

SetLogger sets the test logger implementation for the current process. It must be called only once, at process startup.

func SetLogger(impl Interface)

SetPanicOnExit0 function #

SetPanicOnExit0 sets panicOnExit0 to v. SetPanicOnExit0 should be an internal detail, but alternate implementations of go test in other build systems may need to access it using linkname. Do not remove or change the type signature. See go.dev/issue/67401. go:linkname SetPanicOnExit0

func SetPanicOnExit0(v bool)

Stat function #

Stat calls Logger().Stat, if a logger has been set.

func Stat(name string)

Generated with Arrow