diff options
author | Damian Gryski <[email protected]> | 2023-03-30 18:14:02 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-03-31 09:07:13 +0200 |
commit | 698b1f19c6167800af0683a625ce891f3037c867 (patch) | |
tree | 6c57bf6f5cdad531da65be421d52ec35a41905c0 /src/testing/testing.go | |
parent | e6ccdd9d1a2263f2e55982451c4a980c119e8167 (diff) | |
download | tinygo-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.go | 16 |
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 } |