Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a race detected only if a test times out #3808

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Register signal handler before cmd.Start()
  • Loading branch information
patrickmscott committed Jan 2, 2024
commit d3483d4926f1479d28b7a8c291b97689d4deca9e
6 changes: 4 additions & 2 deletions go/tools/bzltestutil/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func Wrap(pkg string) error {
if !filepath.IsAbs(exePath) && strings.ContainsRune(exePath, filepath.Separator) && chdir.TestExecDir != "" {
exePath = filepath.Join(chdir.TestExecDir, exePath)
}

c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM)

cmd := exec.Command(exePath, args...)
cmd.Env = append(os.Environ(), "GO_TEST_WRAP=0")
cmd.Stderr = io.MultiWriter(os.Stderr, streamMerger.ErrW)
Expand All @@ -137,8 +141,6 @@ func Wrap(pkg string) error {
// TODO: This never triggers on Windows, even though Go should simulate
// a SIGTERM when Windows asks the process to close. It is not clear
// whether Bazel uses the required graceful shutdown mechanism.
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM)
<-c
cmd.Process.Signal(syscall.SIGTERM)
}()
Expand Down