Help us shape the future of Go! Take the 2026 Go Developer Survey

testwatch

package
v1.4.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testwatch gives a test package a hard wall-clock limit shorter than go test's default ten minutes, so a lock that is never released fails the package in about a minute with a goroutine dump instead of freezing a CI host for fifteen (cam handoff 2026-10-13, the bundle operation-lock hang).

Use it from TestMain in packages that wait on file locks:

func TestMain(m *testing.M) { testwatch.Main(m, 90*time.Second) }

Inputs: the package's *testing.M and the limit. Output: crashes the test binary (exit 2) with all goroutine stacks in the panic message when the limit passes; otherwise the process exits with m.Run's code. Constraints: stdlib only; the limit must be well above the package's normal run time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(m *testing.M, limit time.Duration)

Main runs the tests under a watchdog. It returns after m.Run; since Go 1.15 the test wrapper then exits with m.Run's result, so no os.Exit is needed here.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL