package testlog
import "internal/testlog"
Package testlog provides a back-channel communication path between tests and package os, so that cmd/go can see which environment variables and files a test consults.
Index
- func Getenv(name string)
- func Open(name string)
- func PanicOnExit0() bool
- func SetLogger(impl Interface)
- func SetPanicOnExit0(v bool)
- func Stat(name string)
- type Interface
Functions
func Getenv
func Getenv(name string)
Getenv calls Logger().Getenv, if a logger has been set.
func Open
func Open(name string)
Open calls Logger().Open, if a logger has been set.
func PanicOnExit0
func PanicOnExit0() bool
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 SetLogger
func SetLogger(impl Interface)
SetLogger sets the test logger implementation for the current process. It must be called only once, at process startup.
func SetPanicOnExit0
func SetPanicOnExit0(v bool)
SetPanicOnExit0 sets panicOnExit0 to v.
func Stat
func Stat(name string)
Stat calls Logger().Stat, if a logger has been set.
Types
type Interface
type Interface interface { Getenv(key string) Stat(file string) Open(file string) Chdir(dir string) }
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.
func Logger
func Logger() Interface
Logger returns the current test logger implementation. It returns nil if there is no logger.