Documentation
¶
Overview ¶
Package testbudget is the measured half of forge's fast/slow test tiers: it reads a `go test -short -json` run and reports every test that took longer than the budget.
Under -short a test marked slow (forge/pkg/testkit.Slow, or an `if testing.Short() { t.Skip(...) }` guard) skips, so every test that RAN in a -short run is, by construction, one that claims to be fast. One that took longer than the budget is a slow test nobody marked: it is making the blocking tier slow for everyone. The static half (internal/linter/slowtest) flags slow work it can recognize in source; this catches whatever makes a test slow, after it ran slowly once.
Only top-level tests are judged. That is where the marker goes, and a parent's elapsed time includes its subtests', so a table whose cases are each quick but sum past the budget is still reported — it is still that long in the blocking tier. A t.Parallel test's paused time is excluded by the testing package itself.
Index ¶
Constants ¶
const DefaultBudget = 2 * time.Second
DefaultBudget is the longest a test may take in the fast tier.
Variables ¶
var ErrNoInput = errors.New("no go test -json events in the input")
ErrNoInput is returned when the stream held no `go test -json` events.
Functions ¶
Types ¶
type Overrun ¶
type Overrun struct {
Package string
Test string
Elapsed time.Duration
// File and Line locate the test's declaration (File relative to the
// module root), when Locate could resolve it.
File string
Line int
// Marked reports that the declaration calls testing.Short or
// testkit.Slow in its own body. A marked test that ran over budget is
// either still slow under -short, or the run was not made with -short.
Marked bool
}
Overrun is one top-level test that took longer than the budget.
type Report ¶
type Report struct {
Budget time.Duration
// Ran counts the top-level tests that ran (passed or failed).
Ran int
// Overruns are the tests over budget, slowest first.
Overruns []Overrun
// FailedPackages names the packages that failed or did not build. A
// budget check is no verdict on a red run: `go test -json | forge ...`
// reports only forge's status unless the shell sets pipefail.
FailedPackages []string
}
Report is a judged run.