tailscale.comtailscale.com/util/testenv Index | Files

package testenv

import "tailscale.com/util/testenv"

Package testenv provides utility functions for tests. It does not depend on the `testing` package to allow usage in non-test code.

Index

Functions

func AssertInTest

func AssertInTest()

AssertInTest panics if called outside of a test binary.

func InParallelTest

func InParallelTest(t TB) (isParallel bool)

InParallelTest reports whether t is running as a parallel test.

Use of this function taints t such that its Parallel method (assuming t is an actual *testing.T) will panic if called after this function.

func InTest

func InTest() bool

InTest reports whether the current binary is a test binary.

Types

type TB

type TB interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
	Name() string
	Setenv(key, value string)
	Chdir(dir string)
	Skip(args ...any)
	SkipNow()
	Skipf(format string, args ...any)
	Skipped() bool
	TempDir() string
	Context() context.Context
}

TB is testing.TB, to avoid importing "testing" in non-test code.

Source Files

testenv.go

Version
v1.84.0 (latest)
Published
May 21, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
1 day ago

Tools for package owners.