From: Pierre Gimalac Date: Tue, 3 Feb 2026 13:25:23 +0000 (+0100) Subject: cmd/go: do not collect build information for test packages when not needed X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b464a924a9bdd00627cbc3baca86a0e042fccb8a;p=gostls13.git cmd/go: do not collect build information for test packages when not needed When build information is not needed for go list output (when -export=false and Stale and StaleReason fields are not printed), the "SuppressBuildInfo" option is set to true, so that cmd/go/internal/load does not collect it (in particular VCS information, which is costly to compute). However the option is only checked in "PackagesAndErrors", not in "TestPackagesAndErrors", so when running go list -test=true, build information is still collected, significantly increasing the duration of the command. This CL updates TestPackagesAndErrors to check SuppressBuildInfo before calling setBuildInfo, like PackagesAndErrors does. Fixes #77419 Change-Id: I13f60d179c26d79d94899498f76ba9093566eeb6 Reviewed-on: https://go-review.googlesource.com/c/go/+/740901 Reviewed-by: Michael Matloob Reviewed-by: Ian Alexander Auto-Submit: Ian Alexander LUCI-TryBot-Result: Go LUCI Reviewed-by: Sean Liao --- diff --git a/src/cmd/go/internal/load/test.go b/src/cmd/go/internal/load/test.go index e5c074fa19..f9bdd5e1fc 100644 --- a/src/cmd/go/internal/load/test.go +++ b/src/cmd/go/internal/load/test.go @@ -294,7 +294,7 @@ func TestPackagesAndErrors(loaderstate *modload.State, ctx context.Context, done pb := p.Internal.Build pmain.DefaultGODEBUG = defaultGODEBUG(loaderstate, pmain, pb.Directives, pb.TestDirectives, pb.XTestDirectives) - if pmain.Internal.BuildInfo == nil || pmain.DefaultGODEBUG != p.DefaultGODEBUG { + if !opts.SuppressBuildInfo && (pmain.Internal.BuildInfo == nil || pmain.DefaultGODEBUG != p.DefaultGODEBUG) { // Either we didn't generate build info for the package under test (because it wasn't package main), or // the DefaultGODEBUG used to build the test main package is different from the DefaultGODEBUG // used to build the package under test. If we didn't set build info for the package under test