[go] testing: print names of running tests on test timeout

36 views
Skip to first unread message

Bryan Mills (Gerrit)

unread,
Oct 28, 2022, 10:05:08 AM10/28/22
to Russ Cox, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Russ Cox.

Patch set 1:Code-Review +2

View Change

2 comments:

To view, visit change 446176. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e
Gerrit-Change-Number: 446176
Gerrit-PatchSet: 1
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Comment-Date: Fri, 28 Oct 2022 14:05:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Gopher Robot <go...@golang.org>
Gerrit-MessageType: comment

Bryan Mills (Gerrit)

unread,
Oct 28, 2022, 10:05:13 AM10/28/22
to Russ Cox, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Russ Cox.

Bryan Mills removed a vote from this change.

View Change

Removed TryBot-Result-1 by Gopher Robot <go...@golang.org>

To view, visit change 446176. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e
Gerrit-Change-Number: 446176
Gerrit-PatchSet: 1
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-MessageType: deleteVote

Bryan Mills (Gerrit)

unread,
Oct 31, 2022, 1:39:30 PM10/31/22
to Russ Cox, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Russ Cox.

Patch set 2:Code-Review +2

View Change

1 comment:

  • Patchset:

    • Patch Set #1:

      If it goes away I'm going to assume it's unrelated to this CL.

      I filed #56498 for the failure mode I was seeing locally. That one is 100% reproducible for me, so I expect that this `encoding/xml` failure probably is too.

To view, visit change 446176. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e
Gerrit-Change-Number: 446176
Gerrit-PatchSet: 2
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Comment-Date: Mon, 31 Oct 2022 17:39:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Bryan Mills <bcm...@google.com>
Comment-In-Reply-To: Gopher Robot <go...@golang.org>
Comment-In-Reply-To: Russ Cox <r...@golang.org>
Gerrit-MessageType: comment

Gopher Robot (Gerrit)

unread,
Nov 1, 2022, 10:20:36 AM11/1/22
to Russ Cox, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Bryan Mills, golang-co...@googlegroups.com

Gopher Robot submitted this change.

View Change



2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: Bryan Mills: Looks good to me, approved Russ Cox: Run TryBots; Automatically submit change Gopher Robot: TryBots succeeded
testing: print names of running tests on test timeout

Track the running tests and when they started,
so that we can report the running tests on a test timeout.

% go test -timeout=5s
panic: test timed out after 5s
running tests:
TestTCPSpuriousConnSetupCompletion (4s)

... stack traces as usual ...

% go test -run=Script -timeout=10s cmd/go
vcs-test.golang.org rerouted to http://127.0.0.1:65168
https://vcs-test.golang.org rerouted to https://127.0.0.1:65169
go test proxy running at GOPROXY=http://127.0.0.1:65170/mod
panic: test timed out after 10s
running tests:
TestScript (10s)
TestScript/mod_get_patchcycle (0s)
TestScript/mod_get_prefer_incompatible (0s)
TestScript/mod_get_promote_implicit (0s)
TestScript/mod_get_pseudo (0s)
TestScript/mod_get_pseudo_other_branch (0s)
TestScript/mod_get_pseudo_prefix (0s)
TestScript/mod_get_test (0s)
TestScript/mod_get_trailing_slash (0s)
TestScript/mod_get_update_unrelated_sum (0s)
TestScript/mod_gobuild_import (0s)
TestScript/mod_gomodcache (0s)
TestScript/mod_gonoproxy (0s)
TestScript/mod_load_badchain (0s)
TestScript/mod_overlay (0s)
TestScript/test_fuzz_minimize (6s)
TestScript/test_fuzz_minimize_dirty_cov (7s)

... stack traces as usual ...

Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/446176
Run-TryBot: Russ Cox <r...@golang.org>
TryBot-Result: Gopher Robot <go...@golang.org>
Reviewed-by: Bryan Mills <bcm...@google.com>
Auto-Submit: Russ Cox <r...@golang.org>
---
M src/testing/testing.go
1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/src/testing/testing.go b/src/testing/testing.go
index 235ab0a..e694b6c 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -381,6 +381,7 @@
"runtime"
"runtime/debug"
"runtime/trace"
+ "sort"
"strconv"
"strings"
"sync"
@@ -477,6 +478,8 @@
testlogFile *os.File

numFailed atomic.Uint32 // number of test failures
+
+ running sync.Map // map[string]time.Time of running, unpaused tests
)

type chattyFlag struct {
@@ -1363,6 +1366,7 @@
if t.chatty != nil {
t.chatty.Updatef(t.name, "=== PAUSE %s\n", t.name)
}
+ running.Delete(t.name)

t.signal <- true // Release calling test.
<-t.parent.barrier // Wait for the parent test to complete.
@@ -1371,6 +1375,7 @@
if t.chatty != nil {
t.chatty.Updatef(t.name, "=== CONT %s\n", t.name)
}
+ running.Store(t.name, time.Now())

t.start = time.Now()
t.raceErrors += -race.Errors()
@@ -1474,15 +1479,16 @@
// complete even if a cleanup function calls t.FailNow. See issue 41355.
didPanic := false
defer func() {
+ // Only report that the test is complete if it doesn't panic,
+ // as otherwise the test binary can exit before the panic is
+ // reported to the user. See issue 41479.
if didPanic {
return
}
if err != nil {
panic(err)
}
- // Only report that the test is complete if it doesn't panic,
- // as otherwise the test binary can exit before the panic is
- // reported to the user. See issue 41479.
+ running.Delete(t.name)
t.signal <- signal
}()

@@ -1595,6 +1601,8 @@
if t.chatty != nil {
t.chatty.Updatef(t.name, "=== RUN %s\n", t.name)
}
+ running.Store(t.name, time.Now())
+
// Instead of reducing the running count of this test before calling the
// tRunner and increasing it afterwards, we rely on tRunner keeping the
// count correct. This ensures that a sequence of sequential tests runs
@@ -2201,11 +2209,33 @@
m.timer = time.AfterFunc(*timeout, func() {
m.after()
debug.SetTraceback("all")
- panic(fmt.Sprintf("test timed out after %v", *timeout))
+ extra := ""
+
+ if list := runningList(); len(list) > 0 {
+ var b strings.Builder
+ b.WriteString("\nrunning tests:")
+ for _, name := range list {
+ b.WriteString("\n\t")
+ b.WriteString(name)
+ }
+ extra = b.String()
+ }
+ panic(fmt.Sprintf("test timed out after %v%s", *timeout, extra))
})
return deadline
}

+// runningList returns the list of running tests.
+func runningList() []string {
+ var list []string
+ running.Range(func(k, v any) bool {
+ list = append(list, fmt.Sprintf("%s (%v)", k.(string), time.Since(v.(time.Time)).Round(time.Second)))
+ return true
+ })
+ sort.Strings(list)
+ return list
+}
+
// stopAlarm turns off the alarm.
func (m *M) stopAlarm() {
if *timeout > 0 {

To view, visit change 446176. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e
Gerrit-Change-Number: 446176
Gerrit-PatchSet: 5
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages