testshard

command
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Command testshard splits the module's Go tests into CI shards that take about as long as each other.

go list ./... | go run ./scripts/testshard -shard 2 -of 3

prints what shard 2 of 3 tests, one package per line. A package weighs what its tests took in .github/go-test-durations.txt ("seconds import/path" lines); a package the file doesn't list weighs the median. The file can also time a package's tests one by one ("seconds import/path TestName" lines). Such a package is split: its tests are dealt to the shards, and each shard that gets some of them prints "import/path run regexp" naming them, which the package's TestMain applies (internal/testsplit). The shard with the least of the package's time prints "import/path skip regexp" with the other shards' tests instead, so a test the file doesn't time yet runs there. Tests and packages are dealt heaviest first, so everything runs in exactly one shard whatever the file says.

go test -race -count=1 -json ./... | go run ./scripts/testshard -record -split import/path

prints the file's lines from a run of the whole suite, timing the -split packages' tests one by one (make test-durations).

Jump to

Keyboard shortcuts

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