tailscale/cmd/testwrapper
Brad Fitzpatrick 94af1b00fb cmd/testwrapper, tstest: move test sharding out of test code
Previously, sharding required tests to opt in by calling tstest.Shard,
which used a process-global counter to assign each test to a shard.
This had two problems: most tests didn't call it, so they ran on every
shard (defeating the purpose), and shard assignments were unstable
(depended on call order, so adding a test could reshuffle others).

Remove tstest.Shard and tstest.SkipOnUnshardedCI entirely. Instead,
have testwrapper implement sharding automatically for all tests: when
TS_TEST_SHARD=N/M is set, it uses "go list -json" (no compilation) to
find test source files, scans them for top-level Test/Benchmark/
Example/Fuzz function names, and filters by fnv32a(name) % M == N-1.
The filtered names are passed as an anchored -run regex to go test.

Using go list instead of "go test -list" avoids linking the test binary
twice (Go's build cache does not cache test binary linking).

Fixes #19886

Change-Id: I62ab7b3d757324d4c5fd0b5de50c1e3742681791
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-05-27 16:53:17 -07:00
..
flakytest cmd/testwrapper/flakytest: skip flaky tests if TS_SKIP_FLAKY_TESTS set 2026-01-28 08:54:33 -08:00
testdata cmd/testwrapper: surface race reports and skip retries when detected 2026-05-19 21:21:05 -07:00
args_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
args.go cmd/testwrapper: support experimental -cachelink 2026-02-03 09:10:07 -08:00
testwrapper_test.go cmd/testwrapper: surface race reports and skip retries when detected 2026-05-19 21:21:05 -07:00
testwrapper.go cmd/testwrapper, tstest: move test sharding out of test code 2026-05-27 16:53:17 -07:00