wait

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 3 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 is how MyGo's tests wait for what happens elsewhere: on the main thread, in another goroutine or process, in the window system or the file system. They wait until it happened, never for a time.

A test that sleeps and then checks, or that gives up after a few seconds, decides on the speed of the machine: a busy CI runner makes it fail although the code is right, and a longer timeout only makes that rarer. Here a wait ends when its condition holds. Guard bounds it only so that a hang fails the test with what never happened rather than stalling the whole run, and it is not to be tuned: nothing a test waits for takes that long when the code is right. A wait that reaches it found a bug (an event lost to a race, a deadlock, a condition that can't become true), and the fix is in the code or the condition.

Index

Constants

View Source
const Guard = time.Minute

Guard is the longest a wait waits before it fails the test.

Variables

This section is empty.

Functions

func Context

func Context(t testing.TB) context.Context

Context returns a context for calls that wait on one, as Page.EvalContext and FileWatcher.Next do, canceled after Guard or when the test ends.

func For

func For[T any](t testing.TB, what string, ch <-chan T) T

For waits for a value from ch.

func Poll

func Poll(cond func() bool) bool

Poll is Until without a test: it reports whether cond became true before Guard, for helpers that say more when it did not.

func Until

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

Until waits until cond returns true, calling it again and again: right away, then at intervals growing to 20 ms. what says what is waited for, as "the window to close".

Types

This section is empty.

Jump to

Keyboard shortcuts

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