cmd/go: shorten longest 5 tests

Running go test -parallel=1 -v, these are the top 10 tests:

PASS: TestScript/mod_invalid_version 40.14s
PASS: TestScript/build_cache_output 46.82s
PASS: TestScript/get_legacy 48.69s
PASS: TestTestCache 58.44s
PASS: TestScript/mod_get_direct 62.88s
PASS: TestScript/build_pgo_auto_multi 63.49s
PASS: TestScript/build_pgo_auto 70.69s
PASS: TestScript/gcflags_patterns 95.17s
PASS: TestScript/mod_list_compiled_concurrent 124.31s
PASS: TestScript/vet_flags 202.85s

Change the top 5 not to run builds at all, so they don't
have to use -a or clear the go build cache.

mod_get_direct should be replaced with a vcs-test test.
mod_invalid_version should be replaced with a vcs-test test.
get_legacy should be deleted eventually.

Change-Id: Id67c458b1a96c912d89cbece341372c2ef5ee082
Reviewed-on: https://go-review.googlesource.com/c/go/+/504536
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Russ Cox 2023-06-20 10:58:26 -04:00
parent 413e6c0499
commit 36edde9d9f
5 changed files with 32 additions and 73 deletions

View File

@ -3,7 +3,7 @@
[short] skip 'compiles and links executables'
# use default.pgo for a single main package
go build -a -x -pgo=auto -o a1.exe ./a/a1
go build -n -pgo=auto -o a1.exe ./a/a1
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
# check that pgo applied to dependencies
@ -12,25 +12,22 @@ stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
# check that pgo appears in build info
# N.B. we can't start the stdout check with -pgo because the script assumes that
# if the first arg starts with - it is a grep flag.
go version -m a1.exe
stdout 'build\s+-pgo=.*default\.pgo'
stderr 'build\\t-pgo=.*default\.pgo'
# use default.pgo for ... with a single main package
go build -a -x -pgo=auto ./a/...
go build -n -pgo=auto ./a/...
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
# check that pgo appears in build info
go version -m a1$GOEXE
stdout 'build\s+-pgo=.*default\.pgo'
stderr 'build\\t-pgo=.*default\.pgo'
# build succeeds without PGO when default.pgo file is absent
go build -a -x -pgo=auto -o nopgo.exe ./nopgo
go build -n -pgo=auto -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m nopgo.exe
! stdout 'build\s+-pgo='
! stderr 'build\\t-pgo='
# other build-related commands
go install -a -n -pgo=auto ./a/a1
@ -52,30 +49,27 @@ go list -deps -pgo=auto ./a/a1
# -pgo=auto is the default. Commands without explicit -pgo=auto
# should work as -pgo=auto.
go build -a -x -o a1.exe ./a/a1
go build -a -n -o a1.exe ./a/a1
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
# check that pgo appears in build info
go version -m a1.exe
stdout 'build\s+-pgo=.*default\.pgo'
stderr 'build\\t-pgo=.*default\.pgo'
go build -a -x -o nopgo.exe ./nopgo
go build -a -n -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m nopgo.exe
! stdout 'build\s+-pgo='
! stderr 'build\\t-pgo='
# -pgo=off should turn off PGO.
go build -a -x -pgo=off -o a1.exe ./a/a1
go build -a -n -pgo=off -o a1.exe ./a/a1
stderr 'compile.*a1.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
go version -m a1.exe
! stdout 'build\s+-pgo='
! stderr 'build\\t-pgo='
-- go.mod --
module test

View File

@ -1,9 +1,6 @@
# Test go build -pgo=auto flag with multiple main packages.
[short] skip 'compiles and links executables'
env GOBIN=$WORK/bin
go install -a -x -pgo=auto ./a ./b ./nopgo
go install -a -n -pgo=auto ./a ./b ./nopgo
# a/default.pgo applies to package a and (transitive)
# dependencies.
@ -36,16 +33,9 @@ stderr -count=3 'compile.*dep3(/|\\\\)dep3.go'
stderr -count=2 'compile.*-pgoprofile=.*dep3(/|\\\\)dep3\.go'
# check that pgo appears or not in build info as expected
# N.B. we can't start the stdout check with -pgo because the script assumes that
# if the first arg starts with - it is a grep flag.
go version -m $GOBIN/a$GOEXE
stdout 'build\s+-pgo=.*a'${/}'default\.pgo'
go version -m $GOBIN/b$GOEXE
stdout 'build\s+-pgo=.*b'${/}'default\.pgo'
go version -m $GOBIN/nopgo$GOEXE
! stdout 'build\s+-pgo='
stderr 'path\\ttest/a\\n.*build\\t-pgo=.*a(/|\\\\)default\.pgo'
stderr 'path\\ttest/b\\n.*build\\t-pgo=.*b(/|\\\\)default\.pgo'
! stderr 'path\\ttest/nopgo\\n.*build\\t-pgo='
# go test works the same way
go test -a -n -pgo=auto ./a ./b ./nopgo

View File

@ -3,17 +3,15 @@ env GO111MODULE=off
[!compiler:gc] skip 'using -gcflags and -ldflags'
[short] skip
env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
# -gcflags=-e applies to named packages, not dependencies
go build -n -v -gcflags=-e z1 z2
go build -a -n -v -gcflags=-e z1 z2
stderr 'compile.* -p z1.* -e '
stderr 'compile.* -p z2.* -e '
stderr 'compile.* -p y'
! stderr 'compile.* -p [^z].* -e '
# -gcflags can specify package=flags, and can be repeated; last match wins
go build -n -v -gcflags=-e -gcflags=z1=-N z1 z2
go build -a -n -v -gcflags=-e -gcflags=z1=-N z1 z2
stderr 'compile.* -p z1.* -N '
! stderr 'compile.* -p z1.* -e '
! stderr 'compile.* -p z2.* -N '
@ -23,11 +21,11 @@ stderr 'compile.* -p y'
! stderr 'compile.* -p [^z].* -N '
# -gcflags can have arbitrary spaces around the flags
go build -n -v -gcflags=' z1 = -e ' z1
go build -a -n -v -gcflags=' z1 = -e ' z1
stderr 'compile.* -p z1.* -e '
# -gcflags='all=-e' should apply to all packages, even with go test
go test -c -n -gcflags='all=-e' z1
go test -a -c -n -gcflags='all=-e' z1
stderr 'compile.* -p z3.* -e '
# this particular -gcflags argument made the compiler crash
@ -39,31 +37,31 @@ stderr 'PhaseOptions usage'
stderr 'invalid value'
# -ldflags for implicit test package applies to test binary
go test -c -n -gcflags=-N -ldflags=-X=x.y=z z1
go test -a -c -n -gcflags=-N -ldflags=-X=x.y=z z1
stderr 'compile.* -N .*z_test.go'
stderr 'link.* -X=x.y=z'
# -ldflags for explicit test package applies to test binary
go test -c -n -gcflags=z1=-N -ldflags=z1=-X=x.y=z z1
go test -a -c -n -gcflags=z1=-N -ldflags=z1=-X=x.y=z z1
stderr 'compile.* -N .*z_test.go'
stderr 'link.* -X=x.y=z'
# -ldflags applies to link of command
go build -n -ldflags=-X=math.pi=3 my/cmd/prog
go build -a -n -ldflags=-X=math.pi=3 my/cmd/prog
stderr 'link.* -X=math.pi=3'
# -ldflags applies to link of command even with strange directory name
go build -n -ldflags=-X=math.pi=3 my/cmd/prog/
go build -a -n -ldflags=-X=math.pi=3 my/cmd/prog/
stderr 'link.* -X=math.pi=3'
# -ldflags applies to current directory
cd my/cmd/prog
go build -n -ldflags=-X=math.pi=3
go build -a -n -ldflags=-X=math.pi=3
stderr 'link.* -X=math.pi=3'
# -ldflags applies to current directory even if GOPATH is funny
[!case-sensitive] cd $WORK/GoPath/src/my/cmd/prog
go build -n -ldflags=-X=math.pi=3
go build -a -n -ldflags=-X=math.pi=3
stderr 'link.* -X=math.pi=3'
# cgo.a should not be a dependency of internally-linked go package

View File

@ -5,33 +5,12 @@ env GO111MODULE=on
# Regression test for golang.org/issue/29667:
# spurious 'failed to cache compiled Go files' errors.
# This test failed reliably when run with -count=10
# on a Linux workstation.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
wait
-- go.mod --

View File

@ -52,27 +52,25 @@ env GOFLAGS='-unsafeptr'
stderr 'go: parsing \$GOFLAGS: unknown flag -unsafeptr'
env GOFLAGS=
env GOCACHE=$WORK/gocache
# "go test" on a user package should by default enable an explicit list of analyzers.
go test -x -run=none .
go test -n -run=none .
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# An explicitly-empty -vet argument should imply the default analyzers.
go test -x -vet= -run=none .
go test -n -vet= -run=none .
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# "go test" on a standard package should by default disable an explicit list.
go test -x -run=none encoding/binary
go test -n -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
go test -x -vet= -run=none encoding/binary
go test -n -vet= -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# Both should allow users to override via the -vet flag.
go test -x -vet=unreachable -run=none .
go test -n -vet=unreachable -run=none .
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
go test -x -vet=unreachable -run=none encoding/binary
go test -n -vet=unreachable -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
-- go.mod --