From 5b9d2c059830437f02777e872904c8e81eb3460c Mon Sep 17 00:00:00 2001 From: Zhongpeng Lin Date: Wed, 3 Jan 2024 09:50:02 -0800 Subject: [PATCH] registering timeout handler synchronously (#3810) --- go/tools/bzltestutil/timeout.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/go/tools/bzltestutil/timeout.go b/go/tools/bzltestutil/timeout.go index f6d45776a4..70d26d516b 100644 --- a/go/tools/bzltestutil/timeout.go +++ b/go/tools/bzltestutil/timeout.go @@ -22,13 +22,13 @@ import ( ) func RegisterTimeoutHandler() { + // When the Bazel test timeout is reached, Bazel sends a SIGTERM. We + // panic just like native go test would so that the user gets stack + // traces of all running go routines. + // See https://github.com/golang/go/blob/e816eb50140841c524fd07ecb4eaa078954eb47c/src/testing/testing.go#L2351 + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGTERM) go func() { - // When the Bazel test timeout is reached, Bazel sends a SIGTERM. We - // panic just like native go test would so that the user gets stack - // traces of all running go routines. - // See https://github.com/golang/go/blob/e816eb50140841c524fd07ecb4eaa078954eb47c/src/testing/testing.go#L2351 - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGTERM) <-c debug.SetTraceback("all") panic("test timed out")