Skip to content

Commit

Permalink
bzltestutil: restore timeout signal handler
Browse files Browse the repository at this point in the history
In #3920, a new mechanism to
handle test timeout was introduced. However this broke existing tests
that use SIGTERM inside.

Restore the original behavior.
  • Loading branch information
sluongng committed Apr 29, 2024
1 parent 54d8f48 commit 1e8d3b1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion go/tools/builders/generate_test_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ func main() {
// period (15s) expires.
// If TEST_TIMEOUT is not set (e.g., when the test binary is run by Delve for debugging), we don't
// ignore SIGTERM so it can be properly terminated.
signal.Ignore(syscall.SIGTERM)
// We do not panic (like native go test does) because users may legitimately want to use SIGTERM
// in tests.
// 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() {
<-c
}()
}
{{if not .TestMain}}
Expand Down

0 comments on commit 1e8d3b1

Please sign in to comment.