wait

package
v0.148.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wait gives tests load-tolerant waits (gofer-r7am, design docs/design/2026-10-10-flaky-tests-root-cause.md §2.4).

A test that waits for something asynchronous polls a condition until a deadline. Fixed deadlines tuned on an idle machine fail under a full -race run or on a busy Windows CI runner, so every deadline here is multiplied by Scale() (env GOFER_TEST_TIMEOUT_SCALE, default 1) and capped by the test binary's own -timeout. New waits use For / Until; the older per-package waitFor helpers migrate as their tests are touched.

Index

Constants

View Source
const EnvScale = "GOFER_TEST_TIMEOUT_SCALE"

EnvScale names the deadline multiplier, e.g. 3 on a slow CI runner.

Variables

This section is empty.

Functions

func For

func For(t testing.TB, d time.Duration, what string, cond func() (bool, any))

For polls cond until it reports true or the scaled deadline passes; then it fails the test with what and the last value cond observed. cond returns (done, observed).

func Scale

func Scale() float64

Scale returns the deadline multiplier from GOFER_TEST_TIMEOUT_SCALE (≥ 1; an unset, unparsable or smaller value means 1).

func Timeout

func Timeout(t testing.TB, d time.Duration) time.Duration

Timeout scales d and caps it so it ends before the test's own deadline (minus a margin). Use it where a test hands a timeout to the code under test.

func Until

func Until(t testing.TB, d time.Duration, what string, cond func() bool)

Until is For for a plain boolean condition.

Types

This section is empty.

Jump to

Keyboard shortcuts

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