aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2024-02-07 13:10:08 +0700
committerShulhan <m.shulhan@gmail.com>2026-04-14 21:51:40 +0700
commit329eb3a588e02e6078cb364d20f540072f509f04 (patch)
treefec70fb77838763c4024ad74e2942779a674bb4c
parent779b2c6eaca78a60f8e42ebc8a7c47c149f3a9cc (diff)
downloadgo-329eb3a588e02e6078cb364d20f540072f509f04.tar.xz
testing: print the counter if its greater than 1
When test run with "-count=Y" and Y is greater that 1, print a line to indicated the current round of test as "### X/Y".
-rw-r--r--src/cmd/go/testdata/script/test_regexps.txt6
-rw-r--r--src/testing/testing.go4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/test_regexps.txt b/src/cmd/go/testdata/script/test_regexps.txt
index 2f33080a00..b904114a4d 100644
--- a/src/cmd/go/testdata/script/test_regexps.txt
+++ b/src/cmd/go/testdata/script/test_regexps.txt
@@ -3,16 +3,22 @@ go test -cpu=1 -run=X/Y -bench=X/Y -count=2 -v testregexp
# Test the following:
# TestX is run, twice
+stdout -count=1 '^### 1/2$'
stdout -count=2 '^=== RUN TestX$'
stdout -count=2 '^ x_test.go:6: LOG: X running$'
+stdout -count=1 '^### 2/2$'
# TestX/Y is run, twice
+stdout -count=1 '^### 1/2$'
stdout -count=2 '^=== RUN TestX/Y$'
stdout -count=2 '^ x_test.go:8: LOG: Y running$'
+stdout -count=1 '^### 2/2$'
# TestXX is run, twice
+stdout -count=1 '^### 1/2'
stdout -count=2 '^=== RUN TestXX$'
stdout -count=2 '^ z_test.go:10: LOG: XX running'
+stdout -count=1 '^### 2/2'
# TestZ is not run
! stdout '^=== RUN TestZ$'
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 8b7742d85e..add2284edb 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -2733,6 +2733,10 @@ func runTests(modulePath, importPath string, matchString func(pat, str string) (
}
if Verbose() {
t.chatty = newChattyPrinter(t.w)
+
+ if *count > 1 {
+ fmt.Fprintf(t.w, "### %d/%d\n", i+1, *count)
+ }
}
tRunner(t, func(t *T) {
for _, test := range tests {