aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/testing/testing.go
diff options
context:
space:
mode:
authorDamian Gryski <[email protected]>2023-03-30 18:14:02 -0700
committerRon Evans <[email protected]>2023-03-31 09:07:13 +0200
commit698b1f19c6167800af0683a625ce891f3037c867 (patch)
tree6c57bf6f5cdad531da65be421d52ec35a41905c0 /src/testing/testing.go
parente6ccdd9d1a2263f2e55982451c4a980c119e8167 (diff)
downloadtinygo-698b1f19c6167800af0683a625ce891f3037c867.tar.gz
tinygo-698b1f19c6167800af0683a625ce891f3037c867.zip
testing: support -test.count
This makes running benchmarks repeatedly easier.
Diffstat (limited to 'src/testing/testing.go')
-rw-r--r--src/testing/testing.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 9c76f097b..76ff7e694 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -26,6 +26,7 @@ var (
flagVerbose bool
flagShort bool
flagRunRegexp string
+ flagCount int
)
var initRan bool
@@ -40,6 +41,7 @@ func Init() {
flag.BoolVar(&flagVerbose, "test.v", false, "verbose: print additional output")
flag.BoolVar(&flagShort, "test.short", false, "short: run smaller test suite to save time")
flag.StringVar(&flagRunRegexp, "test.run", "", "run: regexp of tests to run")
+ flag.IntVar(&flagCount, "test.count", 1, "run each test or benchmark `count` times")
initBenchmarkFlags()
}
@@ -485,12 +487,14 @@ func runTests(matchString func(pat, str string) (bool, error), tests []InternalT
context: ctx,
}
- tRunner(t, func(t *T) {
- for _, test := range tests {
- t.Run(test.Name, test.F)
- ok = ok && !t.Failed()
- }
- })
+ for i := 0; i < flagCount; i++ {
+ tRunner(t, func(t *T) {
+ for _, test := range tests {
+ t.Run(test.Name, test.F)
+ ok = ok && !t.Failed()
+ }
+ })
+ }
return t.ran, ok
}