-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
commit 1e8d3b15930fc2d97c6b2a53e862bcb52c6d81f9 | ||
Author: Son Luong Ngoc <sluongng@gmail.com> | ||
Date: Mon Apr 29 11:35:20 2024 +0200 | ||
|
||
bzltestutil: restore timeout signal handler | ||
|
||
In https://github.com/bazelbuild/rules_go/pull/3920, a new mechanism to | ||
handle test timeout was introduced. However this broke existing tests | ||
that use SIGTERM inside. | ||
|
||
Restore the original behavior. | ||
|
||
diff --git a/go/tools/builders/generate_test_main.go b/go/tools/builders/generate_test_main.go | ||
index f5b5fcce..b85614ba 100644 | ||
--- a/go/tools/builders/generate_test_main.go | ||
+++ b/go/tools/builders/generate_test_main.go | ||
@@ -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}} |