Documentation
¶
Overview ¶
Command precheck-audits runs, in every package `make precheck` does not already cover, the tests that audit the committed tree, so that a lane meets them in minutes rather than most of an hour into a preflight (iss-2611061656036069, iss-2610230048490215). There is no list of tests to keep: a new audit is chosen by what it does.
A test is an audit here by testreuse.Audits: it reaches the repository tree from its package directory, in its own body, in a same-package helper it names or in a package-level value, and not only through a helper that starts a process. A literal naming an ancestor directory ("../../..") handed to a helper counts, so a test whose helper runs go list there is chosen (the drive's git table in internal/core/implement/loop).
What it cannot see: a tree reached through a helper in another package, other than fsutil.ModuleRoot, and a climb assembled at run time. The command and site packages stay on the name pattern in the Makefile (PRECHECK_AUDIT_TESTS), where hundreds of tests reach the root and a whole selection would not be minutes. TestPrecheckRunsEveryAuditNamedTest (coverageGaps) checks the whole of precheck's choice with a wider detector of its own.
Usage, from the repository root:
go run ./cmd/precheck-audits ./internal/already/run ./internal/also/run
Each argument is a package the recipe runs another way, left out here. It exits with go test's own failure, and 2 when it cannot read a test file, is given something that is not a package path, or finds nothing at all, which would mean the detector stopped working rather than that there are no audits.
Beside a command, for make preflight (iss-2611232155447855):
go run ./cmd/precheck-audits -whole '<packages>' -named '<packages>' -run '<pattern>' -- <command>...
runs precheck's three test lines (the whole packages in full, the named packages' tests the pattern matches, and the audits chosen everywhere else) as narrow runs, each a go test of at most machineload.MaxNarrowPackages packages through `abcd implement load --wait --narrow`, while the command runs (the whole run's gate and its stages). It is beside the whole run's wait, not before it, because a make preflight that has no waiter queued beneath it is a running preflight to every other run's first gate (machineload's queue), so audits run ahead of the wait would hold every other preflight back for as long as they took. One audit run waits or runs at a time, so the account's other narrow places stay free for a drive lane's short check. The first audit run whose go test fails stops the command and every other run, each through the process group it leads (interrupted first, as Ctrl-C at a terminal does, so go test removes its work directory, and killed only after the grace), and the exit is that run's, so make mints no receipt. An audit run that ends without go test's own verdict (the gate timed out, refused at the disk floor or an unusable setting, or could not start) says so with the gate's reason, and the remaining audits stop while the command goes on to decide. Each group's leader is this binary (lead), which kills its group once this process is gone, so a kill of make's own group (abcd land's bound, a drive's lane) leaves no run behind. When the command ends first, its verdict is the exit and the audit runs still going stop: its unit and race stages run every one of these tests. An effective GOFLAGS, under which the narrow gate admits no run, moves onto each run's command line when every flag in it is one a narrow run may carry (make preflight exports -trimpath); otherwise the command runs alone and says so.
It is developer tooling, never part of a release.