cmd/go: skip some tests that run builds in short mode

cmd/go tests that run builds are generally skipped in short mode. This
change will adds skips for some tests that were running builds.

I found these by sorting tests by elapsed time and removing the top
tests that invoked go build. It's our practice to skip tests that run go
build without the -n flag (which prints but doesn't execute commands).

On my work laptop this reduces test run time from about 20 seconds to
about 16 seconds. On my linux workstation it reduces test run time from
about 10 seconds to about 5 seconds.

Change-Id: I18ffcc231df013cb6ac5f5eb3544bed28dadeda8
Reviewed-on: https://go-review.googlesource.com/c/go/+/653775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Matloob 2025-02-28 16:57:44 -05:00
parent 932a4a4bef
commit 37026a7c56
9 changed files with 18 additions and 0 deletions

View File

@ -1147,6 +1147,8 @@ func TestGoListCompiledCgo(t *testing.T) {
} }
func TestGoListExport(t *testing.T) { func TestGoListExport(t *testing.T) {
tooSlow(t, "runs build for -export")
skipIfGccgo(t, "gccgo does not have standard packages") skipIfGccgo(t, "gccgo does not have standard packages")
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()

View File

@ -13,6 +13,8 @@ import (
) )
func TestNoteReading(t *testing.T) { func TestNoteReading(t *testing.T) {
tooSlow(t, "runs build")
// cmd/internal/buildid already has tests that the basic reading works. // cmd/internal/buildid already has tests that the basic reading works.
// This test is essentially checking that -ldflags=-buildid=XXX works, // This test is essentially checking that -ldflags=-buildid=XXX works,
// both in internal and external linking mode. // both in internal and external linking mode.

View File

@ -1,3 +1,5 @@
[short] skip 'runs build'
# Set GOCACHE to a clean directory to ensure that 'go build' has work to report. # Set GOCACHE to a clean directory to ensure that 'go build' has work to report.
[!GOOS:windows] env GOCACHE=$WORK/gocache [!GOOS:windows] env GOCACHE=$WORK/gocache
[GOOS:windows] env GOCACHE=$WORK\gocache [GOOS:windows] env GOCACHE=$WORK\gocache

View File

@ -1,3 +1,5 @@
[short] skip 'runs build'
[!cgo] skip [!cgo] skip
# Require that CC is something that requires a PATH lookup. # Require that CC is something that requires a PATH lookup.

View File

@ -1,3 +1,5 @@
[short] skip 'runs go build'
# We're testing cache behavior, so start with a clean GOCACHE. # We're testing cache behavior, so start with a clean GOCACHE.
env GOCACHE=$WORK/cache env GOCACHE=$WORK/cache

View File

@ -1,6 +1,8 @@
# This test covers the HTTP authentication mechanism over GOAUTH by using a custom authenticator. # This test covers the HTTP authentication mechanism over GOAUTH by using a custom authenticator.
# See golang.org/issue/26232 # See golang.org/issue/26232
[short] skip 'runs build to create authenticators'
env GOPROXY=direct env GOPROXY=direct
env GOSUMDB=off env GOSUMDB=off
mkdir $WORK/bin mkdir $WORK/bin

View File

@ -1,3 +1,5 @@
[short] skip 'runs test'
go test -v -run Test -skip T skip_test.go go test -v -run Test -skip T skip_test.go
! stdout RUN ! stdout RUN
stdout '^ok.*\[no tests to run\]' stdout '^ok.*\[no tests to run\]'

View File

@ -1,3 +1,5 @@
[short] skip 'runs test'
env GO111MODULE=on env GO111MODULE=on
# Issue 35837: "go vet -<analyzer> <std package>" should use the requested # Issue 35837: "go vet -<analyzer> <std package>" should use the requested

View File

@ -1,3 +1,5 @@
[short] skip 'runs go run'
! go work init doesnotexist ! go work init doesnotexist
stderr 'go: directory doesnotexist does not exist' stderr 'go: directory doesnotexist does not exist'
go env GOWORK go env GOWORK