tstest, util/testenv: drop tstest's dependency on the testing package

Change tstest's exported functions (AssertNotParallel, Replace,
Parallel, RequireRoot, SkipOnKernelVersions, MinAllocsPerRun, FixLogs,
UnfixLogs, CheckIsZero, ResourceCheck) to take testenv.TB instead of
testing.TB or *testing.T, so importing tstest from non-test code no
longer links the testing package and its flag registration side
effects into the binary. Add testenv.Verbose to replace the one use of
testing.Verbose, and a deptest check to keep testing out of tstest's
dependency graph.

Callers are unaffected: *testing.T and testing.TB both satisfy
testenv.TB.

Updates tailscale/corp#45223

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Ib373ff66ceff638d071582baf8367245987e9155
This commit is contained in:
Brad Fitzpatrick
2026-07-21 13:03:23 -07:00
committed by Brad Fitzpatrick
parent d11757863d
commit 3ccc7725a3
7 changed files with 47 additions and 17 deletions
+4 -3
View File
@@ -9,8 +9,9 @@ import (
"runtime/pprof"
"slices"
"strings"
"testing"
"time"
"tailscale.com/util/testenv"
)
// ResourceCheck takes a snapshot of the current goroutines and registers a
@@ -19,7 +20,7 @@ import (
// can look at specific routines).
//
// It panics if called from a parallel test.
func ResourceCheck(tb testing.TB) {
func ResourceCheck(tb testenv.TB) {
tb.Helper()
// Set an environment variable (anything at all) just for the
@@ -48,7 +49,7 @@ func ResourceCheck(tb testing.TB) {
// Parse and print goroutines.
start := parseGoroutines(startStacks)
end := parseGoroutines(endStacks)
if testing.Verbose() {
if testenv.Verbose() {
tb.Logf("goroutines start:\n%s", printGoroutines(start))
tb.Logf("goroutines end:\n%s", printGoroutines(end))
}