aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/test/test.go
diff options
context:
space:
mode:
authorPaschalis Tsilias <paschalis.tsilias@gmail.com>2021-04-14 23:55:38 +0300
committerIan Lance Taylor <iant@golang.org>2021-04-28 16:06:21 +0000
commitcbb3f090477de92a7e158050803ef71a5ea825ee (patch)
treef8cb18236c1fb9ca9d19db1c2586086516b8a9b8 /src/cmd/go/internal/test/test.go
parente51246c8819f16cd78d3da01162ca14b432d30bc (diff)
downloadgo-cbb3f090477de92a7e158050803ef71a5ea825ee.tar.gz
go-cbb3f090477de92a7e158050803ef71a5ea825ee.zip
testing: add -shuffle=off|on|N to alter the execution order of tests and benchmarks
This CL adds a new flag to the testing package and the go test command which randomizes the execution order for tests and benchmarks. This can be useful for identifying unwanted dependencies between test or benchmark functions. The flag is off by default. If `-shuffle` is set to `on` then the system clock will be used as the seed value. If `-shuffle` is set to an integer N, then N will be used as the seed value. In both cases, the seed will be reported for failed runs so that they can reproduced later on. Fixes #28592 Change-Id: I62e7dfae5f63f97a0cbd7830ea844d9f7beac335 Reviewed-on: https://go-review.googlesource.com/c/go/+/310033 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/test/test.go')
-rw-r--r--src/cmd/go/internal/test/test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index 847b9357b4..c2f8aed004 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -272,6 +272,13 @@ control the execution of any test:
the Go tree can run a sanity check but not spend time running
exhaustive tests.
+ -shuffle off,on,N
+ Randomize the execution order of tests and benchmarks.
+ It is off by default. If -shuffle is set to on, then it will seed
+ the randomizer using the system clock. If -shuffle is set to an
+ integer N, then N will be used as the seed value. In both cases,
+ the seed will be reported for reproducibility.
+
-timeout d
If a test binary runs longer than duration d, panic.
If d is 0, the timeout is disabled.
@@ -480,6 +487,7 @@ var (
testList string // -list flag
testO string // -o flag
testOutputDir = base.Cwd // -outputdir flag
+ testShuffle shuffleFlag // -shuffle flag
testTimeout time.Duration // -timeout flag
testV bool // -v flag
testVet = vetFlag{flags: defaultVetFlags} // -vet flag